登录

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"
}
# JavaScript
女神的闺蜜爱上我 女神的闺蜜爱上我 2480 天前 1108 次浏览

全部回复(1) 我要回复

  • 过去多啦不再A梦

    过去多啦不再A梦2017-07-05 11:04:19

    file协议,请别这么使用,你得json是正确的,但是如果你使用file协议,不是http协议,那么响应头信息你应该看看,虽然请求头是JSON,你可以试一试跑一下http协议

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

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

    回复
    0
  • 取消 回复 发送