$.ajax({ url: "path/to/your-php-file.php", type: "POST", data: { name: "John", location: "Boston" }, success: function(result){ // do something with result console.log(result); }, error: function(){ console.log("Error occured."); } });
// do something with $name and $location
echo "Hello " . $name . " from " . $location . "!";
?>
使用这些步骤可能会有助于解决问题并使你的Ajax函数能够正确地调用PHP函数。
下一篇:Ajax函数不以异步方式被调用。