javascript - ajax接受json瀏覽器顯示xml解析錯誤:格式不佳?
問題描述
用火狐在本機上測試的ajax
ajax:
(function(){ for(let selectPage = 1; selectPage <= pagesNumber; selectPage++ ) { if(selectPage != page) { btn[selectPage].onclick = function(){ var result = $.ajax({ url: ’./something.json’, // :./asset/host_last data: {'selectPage': selectPage}, dataType: ’JSON’, type: ’get’, success: function(){ console.log('success'); } }); console.log(result.responseText); }; } } })();
something.json:
{ 'IP地址':'something', '主機名':'something', '產(chǎn)品':'something', '應(yīng)用':'something', '機柜編號':'something', '使用狀態(tài)':'something', '備注':'something'}
問題解答
回答1:file協(xié)議,請別這么使用,你得json是正確的,但是如果你使用file協(xié)議,不是http協(xié)議,那么響應(yīng)頭信息你應(yīng)該看看,雖然請求頭是JSON,你可以試一試跑一下http協(xié)議
| | | )_) )_) )_) )___))___))___))____)____)_____) _____|____|____|______
--------- /--------- ^^^^^ ^^^^^ ^^^^ ^^^^^^^ ^^^^^ ^^^
相關(guān)文章:
1. Python中使用超長的List導(dǎo)致內(nèi)存占用過大2. 實現(xiàn)bing搜索工具urlAPI提交3. python - Django有哪些成功項目?4. Python從URL中提取域名5. MySQL主鍵沖突時的更新操作和替換操作在功能上有什么差別(如圖)6. 關(guān)于mysql聯(lián)合查詢一對多的顯示結(jié)果問題7. node.js - windows10下的npm全局路徑的復(fù)原或者將npm徹底刪除?8. 數(shù)據(jù)庫 - Mysql的存儲過程真的是個坑!求助下面的存儲過程哪里錯啦,實在是找不到哪里的問題了。9. 直接打字符不可以嗎?>和>有區(qū)別嗎10. node.js - 微信小程序websocket連接問題
