我需要向返回 json 格式数据的 API 发出请求。此 API 位于此脚本将运行的域的子域上(尽管目前它位于 dev、localhost 的完全不同的域上)
出于某种原因,我认为 jsonp 应该启用这种行为,我错过了什么?
使用 jQuery 1.4.2
$.ajax({
url:'http://another.example.com/returnsJSON.php',
data: data,
dataType:'jsonp',
type: "POST",
error: function(r,error) {
console.log(r);
console.log(error);
},
success:function(r){
console.log(r);
}
});