jQuery ajax禁用解析

Im working with some gaming api, which upon request returns data in json format.

The problem is, api is on different domain so I'm not allowed to use dataType: "json" because of cross domain policy (error: No 'Access-Control-Allow-Origin' header is present on the requested resource). So I tried to use jsonp instead. When I use jsonp, jQuery throws parseError, since data from server is json and not jsonp.

I already tried jsonpCallback and everything of this kind - server still returns json.

I also tried to use xhr.responseText, but is empty. Is there ANY way to just tell jQuery not to parse data - I can parse the string manually, just datatype has to be set on jsonp for server to respond correctly.

And the data is returned from server. I know it is not empty, I can inspect it using developer tools in chrome.

My code:

    url: "http://eu.battle.net/api/wow/character/turalyon/Blargh",
    type: "get",
    data: { fields: "quests" },
    dataType: "json",
    success: function(data, textStatus, jqXHR){
        if(typeof func === "function"){
    error: function(jqXHR, textStatus, errorThrown){
2014/09/29 22:25
  • json
  • ajax
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答