search

Home  >  Q&A  >  body text

javascript - Why does my ajax request report this error?

jquery.js:8630 XMLHttpRequest cannot load file:///C:/Users/Yaphets/Desktop/text/data.json?callback=jQuery214005026997282902079_1493192403330&_=1493192403331. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.


​ $.ajax({
                type:"GET",
                url:"data.json",
                dataType:"jsonp",
                success:function(data){
                  alert(data)
                },
            });
黄舟黄舟2795 days ago556

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-05-19 10:31:57

    If you want to simulate local JSON data, you need to deploy a server, such as apache. Your ajax also involves cross-domain. It is recommended to experiment in a real environment, or do not cross-domain for the time being. Just pass json first.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-19 10:31:57

    dataType changed to json

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-19 10:31:57

    You need a web server.

    reply
    0
  • Cancelreply