Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript PHP, MySQL Query via AJAX

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #33130
    danielando
    Member

    G’day everyone, I am a newbie to AJAX and was wondering if someone could tell me if this is possible.

    I have a form that passes a hidden field value to another php file, which uses that value and queries a MySQL database and displays the results in the form of a drop down list.

    Is it possible to do this via AJAX and have the drop down list appear on the same page as the form is submitted from?

    #72866
    kalps1982
    Member

    Yes, this is possible.

    You can use jQuery Ajax for doing this so. Using jQuery it would be easier for you to implement Ajax functionalities.

    At server side you have to create a PHP file which accepts POST request. On receiving request from Ajax this file would do necessary process and return you dropdown list. (Ajax request can receive response in form of XML, JSON or normal HTML as text form).

    When jQuery Ajax receive response you can use jQuery functionality to dynamically add dropdown in your page by using .append() function.

    #72868
    danielando
    Member

    Would I use something like this:

    $.post(page.php, function(data){

    });

    #86466
    kalps1982
    Member

    yeap! you can use something like that! but remember what kind of content you are sending back from page.php, as that would matter when you want to attach returned response to your page using javascript. Good luck!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.