我在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);
}
});
$.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"
答案 0 :(得分:0)
将option
添加到$.ajax()
jsonpCallback: 'myCallback',
同时将url:
更改为"http://localhost:5133/api/Budget_Tracking?callback=?",
创建一个function
之类的
function myCallback(){
//your code with callback
}