Error: “Origin null is not allowed by Access-Control-Allow-Origin” when loading an XML file with JQuery's ajax method

后端 未结 5 1737
我在风中等你
我在风中等你 2020-11-30 10:27

This is my code:

this.loadMap = function () {
    this._map = null;
    this._width = 0;
    this._height = 0;
    this._playerX = 0;
    this._playerY = 0;
         


        
5条回答
  •  旧时难觅i
    2020-11-30 10:47

    You're testing this in Chrome? What's basically happening is because you're loading the file from your filesystem instead of from a server, Chrome is setting your origin to null even though the resource you're requesting is local to you. If you were to do this from an HTTP server such as Apache, I think it would work just fine.

提交回复
热议问题