javascript - ajax接受json瀏覽器顯示xml解析錯誤:格式不佳?
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-07-05 11:02:19
0
1
1198

用火狐在本機上測試的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)
过去多啦不再A梦

file協議,請別這麼使用,你得json是正確的,但是如果你使用file協議,不是http協議,那麼響應頭信息你應該看看,雖然請求頭是JSON,你可以試一試跑一下http協定

          |    |    | 
         )_)  )_)  )_) 
        )___))___))___)\ 
       )____)____)_____)\ 
     _____|____|____|____\\__ 

--------- /---------
^^^^^ ^^^^^ ^^^^ ^^^^^^^ ^^^^^ ^^^

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!