javascript - Call PHP Method with Ajax -
this question has answer here:
- call php function using jquery ajax 4 answers
i trying call php file's function using ajax. here ajax call :
function getbaseurl() {
var patharray = location.href.split( '/' ); var protocol = patharray[0]; var host = patharray[2]; var url = protocol + '//' + host; return url+"/phpproject2"; } function getpagesaverurl() { return getbaseurl()+"/manager/content_manager/page_saver.php/savetest"; } function savepage() { alert("saving page"); var url = getpagesaverurl(); $.ajax({ type: "post", url: url, data: "name=hello", success: function(response){ alert(response); } }); }
but not getting response script. can call php funciton ajax url parameter?
you cannot call php function ajax url parameter.
you can use parameter ajax call, see following code -
function getpagesaverurl() { return getbaseurl()+"/manager/content_manager/page_saver.php?param=savetest"; }
then in file page_saver.php, need fetch parameter 'param', have value 'savetest', execute function.
try this, let me know if have further query.
Comments
Post a Comment