本教程操作环境:windows7系统、php8.1版、dell g3电脑。
ajax调用php失败怎么办?
ajax请求php报500错误,ajax只能发起get请求,而不能发post请求,否则报500错误
我是大标题1
abc$.ajax({type: "get", // get方式不会报错url: "tmpl.html",datdtype: "html",data: {"username": "username","password": "password"},success: function(data) {$("p").append(data);}});
我是大标题1
abc$.ajax({type: "get", // 虽然是get方式,但是data数据是json数据的序列化,也会报错url: "tmpl.html",datdtype: "html",data: "{%22username%22:%22username%22,%22password%22:%22password%22}",success: function(data) {$("p").append(data);}});
我是大标题1
abc$.ajax({type: "post", // post方式一定会报错url: "tmpl.html",datdtype: "html",data: {"username": "username","password": "password"},success: function(data) {$("p").append(data);}});
(1)所报错误都是一样的:failed to load resource: the server responded with a status of 500 (internal server error)
(2)我是前端工程师,只做前台,不写后台代码的,也就是没有j2ee或者php什么的。
(3)经过测试,如果有后台代码,所有情况都不会报错的。
推荐学习:《php视频教程》
以上就是ajax调用php失败怎么办的详细内容。
