Javascript cross domain - “allow” other domains?

后端 未结 3 1379
青春惊慌失措
青春惊慌失措 2020-12-22 12:10

Description of steps

  1. Write \"callback\" function on my custom page in my domain (called \"MyCallbackCallback\", for the sake of argument)
3条回答
  •  自闭症患者
    2020-12-22 12:34

    It’s not exactly clear from your question, but if you’re trying to use CORS, the server you’re requesting data from should add an Access-Control-Allow-Origin HTTP header, like so:

    Access-Control-Allow-Origin: http://example.org/
    

    Or, if it’s a public resource:

    Access-Control-Allow-Origin: *
    

    Older browsers don’t support CORS. If you need a fully cross-browser-compatible solution, use JSONP.

提交回复
热议问题