2017-06-24 46 views
1

我試圖做一個非常簡單的ajax請求到json api。我使用的是dataType: 'jsonp',因爲它是跨域的,現在我無法將我的頭圍繞CORS。Ajax請求dataype JSONP「未捕獲的SyntaxError:意外的令牌:」

的請求經過狀態200,我可以閱讀所有在Chrome瀏覽器開發工具,網絡選項卡中的用戶,但我仍然得到「未捕獲的SyntaxError:意外的標記:」

這裏是我的代碼:

var url = 'https://api.lookfwd.io/v1/test/users'; 

    export const fetchUsers = function() { 
     return $.ajax({ 
     dataType: "jsonp", 
     url: url, 
     }); 
    } 

關於我該怎麼做的任何想法?

+0

你可以發佈你所得到的響應。 –

回答

0

你有這個來代替: -

dataType: "json",

刪除JSONP使用JSON只

+1

如果我這樣做,那麼我得到一個跨域錯誤。 – Eric

相關問題