how to name a file properly

Discussion in 'HTML' started by richard, Nov 3, 2013.

  1. richard

    richard Guest

    I want to modify a javascript file so that some php script is included.
    So that I can send some data to the database.
    Using an externally linked file, which extension does the javascript file
    now get?
    JS or PHP?
     
    richard, Nov 3, 2013
    #1
    1. Advertising

  2. richard

    Luuk Guest

    On 03-11-2013 18:07, richard wrote:
    > I want to modify a javascript file so that some php script is included.
    > So that I can send some data to the database.
    > Using an externally linked file, which extension does the javascript file
    > now get?
    > JS or PHP?
    >


    if it's a javascript file name it 'something.js'
    if it's PHP name it 'something.php'
    ('something' can be something else... ;)

    Mostly javascript is executed on the client. Therefore it should not
    have the ability top update a database (which is normally at the
    server-side).

    I'm a little bit confused with your remark:
    "I want to modify a javascript file so that some php script is included."

    So, let me ask this question:
    Can you give an example of what you want to do? (in code form)
     
    Luuk, Nov 3, 2013
    #2
    1. Advertising

  3. On Sun, 03 Nov 2013 19:19:04 +0100, Luuk wrote:

    > Can you give an example of what you want to do? (in code form)


    I suspect what he wants to do is set javascript variables from his php.

    But this is guesswork.

    --
    Denis McMahon,
     
    Denis McMahon, Nov 3, 2013
    #3
  4. richard

    richard Guest

    On Sun, 03 Nov 2013 19:19:04 +0100, Luuk wrote:

    > On 03-11-2013 18:07, richard wrote:
    >> I want to modify a javascript file so that some php script is included.
    >> So that I can send some data to the database.
    >> Using an externally linked file, which extension does the javascript file
    >> now get?
    >> JS or PHP?
    >>

    >
    > if it's a javascript file name it 'something.js'
    > if it's PHP name it 'something.php'
    > ('something' can be something else... ;)
    >
    > Mostly javascript is executed on the client. Therefore it should not
    > have the ability top update a database (which is normally at the
    > server-side).
    >
    > I'm a little bit confused with your remark:
    > "I want to modify a javascript file so that some php script is included."
    >
    > So, let me ask this question:
    > Can you give an example of what you want to do? (in code form)


    Check out the javascript used by my site's player.
    When a song is loaded and is actually playing, I need to send that data to
    the database to update the records.
    I'd post the code, but it's rather intense and I'm not sure which part
    would be relevant to post.
     
    richard, Nov 3, 2013
    #4
  5. richard <> writes:
    <snip>
    >> On 03-11-2013 18:07, richard wrote:
    >>> I want to modify a javascript file so that some php script is included.
    >>> So that I can send some data to the database.

    <snip>
    > Check out the javascript used by my site's player.
    > When a song is loaded and is actually playing, I need to send that data to
    > the database to update the records.


    You need to read up on making HTTP requests from ECMAScript. You might
    start here: http://en.wikipedia.org/wiki/XMLHttpRequest

    Your description is a little odd, but it sounds as if you want the
    client side script to do something on the server side, and that's done
    with an HTTP request (it used to be call AJAX). Of course, it is
    sometimes possible to get it done by simply clicking a button, either
    directly of by script control.

    --
    Ben.
     
    Ben Bacarisse, Nov 3, 2013
    #5
  6. richard

    Lewis Guest

    In message <zo9g4c8vpyva$>
    richard <> wrote:
    > I want to modify a javascript file so that some php script is included.
    > So that I can send some data to the database.
    > Using an externally linked file, which extension does the javascript file
    > now get?


    That depends on how your server will handle the files and on exactly how
    the files are used. For example, at least on apache, if you are
    including the files in an html document, then the extensions don't
    matter at all on the included files. This seems the most likely.

    --
    Q: Does anyone know how many LOCs were in the Space Shuttle' codebase?
    A: 45. It was written in perl (paraphrased Slashdot discussion)
     
    Lewis, Nov 3, 2013
    #6
  7. richard

    Lewis Guest

    In message <>
    Lewis <> wrote:
    > In message <zo9g4c8vpyva$>
    > richard <> wrote:


    Goddamnit!

    --
    Vampires have risen from the dead, the grave and the crypt, but have
    never managed it from the cat. --Witches Abroad
     
    Lewis, Nov 3, 2013
    #7
  8. On Sun, 03 Nov 2013 22:25:17 +0000, Lewis wrote:

    > In message <zo9g4c8vpyva$>
    > richard <> wrote:
    >> I want to modify a javascript file so that some php script is included.
    >> So that I can send some data to the database.
    >> Using an externally linked file, which extension does the javascript
    >> file now get?

    >
    > That depends on how your server will handle the files and on exactly how
    > the files are used. For example, at least on apache, if you are
    > including the files in an html document, then the extensions don't
    > matter at all on the included files. This seems the most likely.


    It does matter if he wants to deliver javascript from a php file, as the
    file will have to be .php for the webserver to hand it off to the php
    preprocessor, but it seems that's not what he wants to do.

    --
    Denis McMahon,
     
    Denis McMahon, Nov 3, 2013
    #8
  9. richard

    Tim Streater Guest

    In article <l56m81$50j$>, Denis McMahon
    <> wrote:

    > On Sun, 03 Nov 2013 22:25:17 +0000, Lewis wrote:
    >
    > > In message <zo9g4c8vpyva$>
    > > richard <> wrote:
    > >> I want to modify a javascript file so that some php script is included.
    > >> So that I can send some data to the database.
    > >> Using an externally linked file, which extension does the javascript
    > >> file now get?

    > >
    > > That depends on how your server will handle the files and on exactly how
    > > the files are used. For example, at least on apache, if you are
    > > including the files in an html document, then the extensions don't
    > > matter at all on the included files. This seems the most likely.

    >
    > It does matter if he wants to deliver javascript from a php file, as the
    > file will have to be .php for the webserver to hand it off to the php
    > preprocessor, but it seems that's not what he wants to do.


    My impression, BICBW, is that he wants to "mix" some php into his js
    that will somehow execute in the browser and that he can use to update
    his database.

    What he needs is to make an ajax request.

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
     
    Tim Streater, Nov 3, 2013
    #9
  10. On Sun, 03 Nov 2013 23:41:32 +0000, Tim Streater wrote:

    > In article <l56m81$50j$>, Denis McMahon
    > <> wrote:


    >> On Sun, 03 Nov 2013 22:25:17 +0000, Lewis wrote:


    >> > In message <zo9g4c8vpyva$>
    >> > richard <> wrote:


    >> >> I want to modify a javascript file so that some php script is
    >> >> included.
    >> >> So that I can send some data to the database.
    >> >> Using an externally linked file, which extension does the javascript
    >> >> file now get?


    >> > That depends on how your server will handle the files and on exactly
    >> > how the files are used. For example, at least on apache, if you are
    >> > including the files in an html document, then the extensions don't
    >> > matter at all on the included files. This seems the most likely.


    >> It does matter if he wants to deliver javascript from a php file, as
    >> the file will have to be .php for the webserver to hand it off to the
    >> php preprocessor, but it seems that's not what he wants to do.


    > My impression, BICBW, is that he wants to "mix" some php into his js
    > that will somehow execute in the browser and that he can use to update
    > his database.


    > What he needs is to make an ajax request.


    Yeah, I thought from the original post that he was trying to pass data
    values from php to js, but in fact he's going in the other direction.

    I'd just like to state here and now that for my own sanity, I have no
    intention of even trying to help richard implement AJAX / XMLHttpRequest,
    especially as after 10[1] years of building this website he obviously
    still hasn't got the conceptual differences between get and post straight
    in his head yet.

    [1] Is it less? It seems longer.

    --
    Denis McMahon,
     
    Denis McMahon, Nov 4, 2013
    #10
  11. richard

    Ben C Guest

    On 2013-11-03, richard <> wrote:
    [...]
    >> So, let me ask this question:
    >> Can you give an example of what you want to do? (in code form)

    >
    > Check out the javascript used by my site's player. When a song is
    > loaded and is actually playing, I need to send that data to the
    > database to update the records.


    It's not usually a good idea to send code directly from the browser to
    the server where you just execute it.

    It's not too hard for someone to send different code that then runs on
    your server and does something malicious etc.

    I would construct the return messages on the server, encrypt them there,
    and embed them in the page. Then when someone plays the song, you send
    back the message and decrypt it again on the server, throwing it away if
    it doesn't decrypt to what you're expecting.
     
    Ben C, Nov 5, 2013
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    898
    Roedy Green
    Jan 2, 2006
  2. ding feng
    Replies:
    2
    Views:
    2,917
    ding feng
    Jun 25, 2003
  3. Bobby Chamness
    Replies:
    2
    Views:
    2,446
    Joe Smith
    Apr 22, 2007
  4. Jack-2
    Replies:
    3
    Views:
    336
    Jack-2
    Dec 24, 2003
  5. Java  script  Dude

    IE name="name" & form.name property bug

    Java script Dude, Jun 29, 2004, in forum: Javascript
    Replies:
    5
    Views:
    284
    Java script Dude
    Jun 30, 2004
Loading...

Share This Page