【发布时间】:2013-12-30 16:23:39
【问题描述】:
我在 MVC 中有一个 WEB API, 我正在尝试使用 Ajax 在 jquery 中使用相同的内容
$.ajax({
type: "POST",
dataType: "jsonp",
contentType: "application/javascript",
data: data,
async: false,
url: "http://localhost:5133/api/Budget_Tracking",
success: function (jsonData) {
console.log(jsonData);
},
error: function (request, textStatus, errorThrown) {
console.log(request.responseText);
console.log(textStatus);
console.log(errorThrown);
}
});
执行此代码时出现错误::
错误是
"jQuery1102043945081951096654_1388391275993 was not called"
【问题讨论】:
-
http://localhost:5133/api/Budget_Tracking你是从这里得到json吗?服务器是否已配置为使用cors发送 json。 -
是的,它正在发送 JSON
-
contentType: "application/javascript",尝试删除它。或者改成这个contentType: "application/json", -
也试过这个 :: 不工作
标签: jquery ajax asp.net-web-api