ajax fails to call php because ajax can only initiate GET requests, but not POST requests, otherwise a 500 error will be reported. The solution is to use the GET method, and its syntax is such as "$.ajax({type: "GET",url: "tmpl.html",datdType: "html",data: {"username": "username","password":...}".
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
What should I do if ajax fails to call php?
ajax When requesting php, a 500 error is reported. Ajax can only initiate a GET request, but not a POST request. Otherwise, a 500 error is reported.
I am the title 1abc $.ajax({ type: "GET", // GET方式不会报错 url: "tmpl.html", datdType: "html", data: { "username": "username", "password": "password" }, success: function(data) { $("p").append(data); } });
PHP Video Tutorial
"The above is the detailed content of What to do if ajax fails to call php. For more information, please follow other related articles on the PHP Chinese website!