Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    26
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Javascript + PHP Question

    I don't think this will be too difficult to do, but I'm working on a project where a user will be uploading a file to my server. I'm not at my machine right now that has code, so I apologize for that, though I'm simply curious, on a simple level what needs to be done.

    1) I have a user inputting information into a lightbox, and have the "submit" click captured in javascript. (using a jquery lightbox btw).

    2) I have a function that I'm going to have to either call or move over, or whatever is easiest, that handles all the communication with our server/database. This function is in PHP.

    What's the best way to do something like this,
    Code:
    // syntax is probably wrong, but don't worry about that
    $(#mytag).click (function(){
            // I'm here in my .js
            ohhaiPHPFunction();
    });
    Thanks in advance =)

  • #2
    New Coder
    Join Date
    May 2009
    Posts
    26
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I'll post that I understand the difference of how the javascript is client side code, and the PHP runs server-side. So really, what's the general approach when I have a popup in a lightbox, and need to initiate a server side upload of a file from there?

    I've seen sites do this through a lightbox before so I know it's possible to do without reloading the page. Anywho, thanks.

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    26
    Thanks
    2
    Thanked 0 Times in 0 Posts
    So, as Mr. Internet pointed out. Ajax via jquery is probably the way to go to do this. Thanks me, appreciate the help! =)

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    AJAX and plain javascript (neither JQuery, nor other frameworks) is probably the best way. But this is another topic
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •