文章詳情頁(yè)
解決ajax異步請(qǐng)求返回的是字符串問(wèn)題
瀏覽:103日期:2022-06-11 11:05:46
1.返回結(jié)果差異
js獲取后打印res.code無(wú)結(jié)果。因?yàn)榉祷財(cái)?shù)據(jù)格式不正確。
php文件添加header頭:
header("Content-Type:application/json;");
或者。j s 添加
contentType: "application/json; charset=utf-8",dataType: "json",$.ajax({ url:"../data/insert_category.php?article_type=" + value, contentType: "application/json; charset=utf-8", dataType: "json", success:function(res){ console.log("異步成功"); console.log(res); console.log(res.code); }, error:function(){ console.log("異步失敗"); } })
總結(jié)
以上所述是小編給大家介紹的解決ajax異步請(qǐng)求返回的是字符串問(wèn)題,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)網(wǎng)站的支持!
標(biāo)簽:
Ajax
上一條:在layer彈出層中通過(guò)ajax返回html拼接字符串填充數(shù)據(jù)的方法下一條:$.ajax中contentType: “application/json” 的用法詳解
相關(guān)文章:
1. 利用ajax+php實(shí)現(xiàn)商品價(jià)格計(jì)算2. 解決AJAX返回狀態(tài)200沒(méi)有調(diào)用success的問(wèn)題3. Ajax實(shí)現(xiàn)表格中信息不刷新頁(yè)面進(jìn)行更新數(shù)據(jù)4. axios和ajax的區(qū)別點(diǎn)總結(jié)5. 詳談ajax返回?cái)?shù)據(jù)成功 卻進(jìn)入error的方法6. 爬取今日頭條Ajax請(qǐng)求7. laravel ajax curd 搜索登錄判斷功能的實(shí)現(xiàn)8. layui Ajax請(qǐng)求給下拉框賦值的實(shí)例9. Ajax請(qǐng)求超時(shí)與網(wǎng)絡(luò)異常處理圖文詳解10. Ajax獲取php返回json數(shù)據(jù)動(dòng)態(tài)生成select下拉框的實(shí)例
排行榜
