Cross Domain Ajax get Request

自闭症网瘾萝莉.ら 提交于 2019-12-13 04:55:22

问题


I'd like to ask a question for cross-domain Get request via Ajax. My ajax request is Like that

var currency_path="http://forex.cbm.gov.mm/api/latest";

$.ajax({  
    url: currency_path,  
    crossDomain:true,  
    type:"GET",  
    dataType:'jsonp',  
    async:false,  
    success: function(data){  
        console.log(data);  
 },  
error: function(){  
     alert('failure');  
}  
}).done(function(msg) {  
    console.log(msg);             
});

I got the response but i can't trace that Any Suggestion ?


回答1:


Look in your JavaScript error console:

Uncaught SyntaxError: Unexpected token :

You have dataType:'jsonp', but the URL is returning JSON.

You can't parse JSON as JSONP, there are different data formats.

Use some other technique to access the data.



来源:https://stackoverflow.com/questions/25636932/cross-domain-ajax-get-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!