• JQuery get data and send to PHP instantaneously

    BrittneTabor Member

    I’m in the process of planning to create a page with PHP and Jquery.

    First name:
    Last name:

    What I want to do is get jquery to submit the data from each input box as soon as the user types it to a PHP file and then return the results from the PHP on the same page without refreshing. (This process continues as the user manipulates the data on the text boxes).

  • ShikhaTan Member

    Simple. Decide what action you want to trigger the event on, it can be onkeyup, or on blur etc – that’s for you to decide, then bind an event, for example, on blur would be

    $("#firstname").blur(function() {
    
    getResultsfromajax();
    
    });
    
    function getResultsfromajax() {
    $.ajax({//options});
    OR
    $.post([url], [data]);
    OR
    $.get([url], [data]);
    
    }
    

    Of course, you’d want to give your input ID’s to bind them to jQuery like I did above.

    (yes, this advice doesn’t give you a complete answer, but I’ve given you enough for you to hopefully research, you’ll learn more this way than just a complete code example.)
    thecodingdude is offline View user’s profile Send private message

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
en_USEnglish