【发布时间】:2014-05-26 19:36:49
【问题描述】:
在 php 我做echo json_encode($dump);
如果使用 php 回显它,我会得到 {"load":"0.64 0.58 0.52 2\/361 12978\n","procs":"8\n"}
比我使用 dataType:jsonp 发出 CORS 请求
$(function () {
$.ajax({
type: "POST",
ContentType: 'application/json; charset=utf-8',
url: 'http://labs.isaumya.com/loadtest/load',
dataType: "jsonp",
success: function (response) {
console.log(response.data);
},
error: function (xhr, status, error) {
console.log(error);
}
});
});
我在控制台上收到此错误:
【问题讨论】:
-
在jsonp的情况下你需要使用回调作为响应。
标签: php jquery json jsonp cors