| | |
Call a specific PHP function with AJAX?
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 7
Reputation:
Solved Threads: 0
Hi guys,
I was wondering if it was possible to call a specific PHP function using AJAX instead of calling a whole page. An example:
I already have a PHP function (in a class) that retrieves the provinces/states from the database based on the country. I was wondering if it was possible to call this function instead of having to make a new file (in this case FindProvinces.php) that calls the function. Thanks in advance.
I was wondering if it was possible to call a specific PHP function using AJAX instead of calling a whole page. An example:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function MakeRequest() { var xmlHttp = getXMLHTTP(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { document.getElementById('provinceDiv').innerHTML = xmlHttp.responseText; } } xmlHttp.open("GET", "FindProvinces.php", true); xmlHttp.send(null); }
I already have a PHP function (in a class) that retrieves the provinces/states from the database based on the country. I was wondering if it was possible to call this function instead of having to make a new file (in this case FindProvinces.php) that calls the function. Thanks in advance.
I am sure PHP has some sort of MVC architecture implementation wherein the controller handles the requests and delegates it to an appropriate entity. Maybe posting this PHP related query in the PHP sub-forum might bring out some good responses since this seems more like a server-side url mapping/configuration issue.
javascript Syntax (Toggle Plain Text)
// Here /operations is mapped to a PHP file which acts as a // controller and performs the delegation activity based on // the operation requested, here, find-provinces xmlHttp.open("GET", "/operations/find-provinces", true); xmlHttp.send(null);
I don't accept change; I don't deserve to live.
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
![]() |
Similar Threads
- call function (JavaScript / DHTML / AJAX)
- AJAX : Am i right with the concept? (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: need help for web chat using php & ajax
- Next Thread: JavaScript-iframe in Firefox-looking for help
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp ajaxjspservlets animate api automatically blackjack browser bug calendar captchaformproblem checkbox child class close cookies createrange() cursor dependent disablefirebug dom dropdown editor element embed engine events explorer ext file firehose flash form forms game google gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha media microsoft mysql object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php player post progressbar rated regex runtime scroll search security session shopping size software sql star stars stretch synchronous text textarea tweet twitter unicode validation web website window windowsxp wysiwyg \n






