- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › PHP, MySQL Query via AJAX
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?
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.
Would I use something like this:
$.post(page.php, function(data){
});
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!