jQuery XML REST Access-Control-Allow-Origin

前端 未结 3 1623
孤独总比滥情好
孤独总比滥情好 2020-12-11 03:56

I am calling Version One REST API and keep getting XMLHttpRequest cannot load https://www10.v1host.com/... Origin http://localhost:8080 is not allowed by Access-Contro

3条回答
  •  难免孤独
    2020-12-11 04:46

    i know it's an old question but i think there is an better answer, via jQuery documentation:

    dataType

    multiple, space-separated values: As of jQuery 1.5, jQuery can convert a dataType from what it received in the Content-Type header to what you require. For example, if you want a text response to be treated as XML, use "text xml" for the dataType. You can also make a JSONP request, have it received as text, and interpreted by jQuery as XML: "jsonp text xml." Similarly, a shorthand string such as "jsonp xml" will first attempt to convert from jsonp to xml, and, failing that, convert from jsonp to text, and then from text to xml.

提交回复
热议问题