search

Home  >  Q&A  >  body text

ajax accept json browser shows xml parsing error: poorly formatted?

Ajax tested on this machine using Firefox

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"
}
女神的闺蜜爱上我女神的闺蜜爱上我2743 days ago1272

reply all(1)I'll reply

  • 过去多啦不再A梦

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

    File protocol, please don’t use it like this. Your json is correct, but if you use the file protocol, not the http protocol, then you should look at the response header information. Although the request header is JSON, you can try running http Agreement

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

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

    reply
    0
  • Cancelreply