php入門到就業線上直播課:進入學習Apipost = Postman + Swagger + Mock + Jmeter 超好用的API調試工具:點擊使用
本教程操作環境: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失敗怎么辦的詳細內容,更多請關注php中文網其它相關文章!
關鍵詞: ajax