| | |
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.
![]() |
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 |
acid2 ajax ajaxcode ajaxhelp animate automatically beta box bug calendar captcha cart checkbox child class column cookies createrange() css cursor decimal design dom download dropdown editor element engine enter error events explorer file focus form forms frameworks google gwt html htmlform ie8 iframe image() images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jump listbox math matrixcaptcha menu microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent pdf php player post problem progressbar prototype rated rating regex runtime scale scroll search select session shopping size sql star starrating stars text textarea validation w3c web website window windowofwords windowsxp wysiwyg xml \n






