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', '產品':'something', '應用':'something', '機柜編號':'something', '使用狀態':'something', '備注':'something'}
問題解答
回答1:file協議,請別這么使用,你得json是正確的,但是如果你使用file協議,不是http協議,那么響應頭信息你應該看看,雖然請求頭是JSON,你可以試一試跑一下http協議
| | | )_) )_) )_) )___))___))___))____)____)_____) _____|____|____|______
--------- /--------- ^^^^^ ^^^^^ ^^^^ ^^^^^^^ ^^^^^ ^^^
相關文章:
1. docker安裝后出現Cannot connect to the Docker daemon.2. 為什么我ping不通我的docker容器呢???3. android - webview 自定義加載進度條4. mysql - 怎么讓 SELECT 1+null 等于 15. javascript - 微信音樂分享6. 網頁爬蟲 - 用Python3的requests庫模擬登陸Bilibili總是提示驗證碼錯誤怎么辦?7. javascript - 微信小程序封裝定位問題(封裝異步并可能多次請求)8. 并發模型 - python將進程池放在裝飾器里為什么不生效也沒報錯9. linux - openSUSE 上,如何使用 QQ?10. python 怎樣用pickle保存類的實例?
