Is it possible to call a php function on jquery ajax call.When i tried to do this i get function not defined error on php function
$.ajax({
type:"POST",
url:"x.php?z=" + id,
cache:false,
success: function(data)
{
<?php xcz(); ?>
}
});
$.ajax({
type:"POST",
url:"x.php?z=" + id,
cache:false,
success: function(data)
{
anotherFunction();
}
});
function anotherFunction(){
$.ajax({
type:"POST",
url:"anotherFile.php",
cache:false,
success: function(data)
{
//do something else;
}
});
}
That's not possible. PHP and javascript run on different computers. PHP runs on the server, and javascript runs in the browser. At the time the javascript is being executed, that server has already executed the PHP code, and has sent that the the browser.
The only way you can achieve such a thing is making an additional Ajax request.
Not possible. Because jQuery (javascript) runs on client side, php runs on server side.
When page loaded on browser, php's job is finished.
You can call just javascript's function like this approach.