我尝试在apiusing 中调用一个方法jquery,但我收到一条错误消息
XML 解析错误:找不到根元素
API方法:
[HttpGet]
public async Task<IActionResult> GetJob(int id)
{
var result = await this.DB.GetJob(id);
return Ok(result);
}
查询:
function InvokeAjax (controller, action, method, query = {}, body = {}, callback) {
let url = "/Secure/" + controller + "/" + action;
if (query.length > 0) {
let tmp;
let i = 1;
query.each(function (index) {
if (i === 1) {
tmp = "?";
}
else {
tmp += "&";
}
tmp = this.key + "=" + this.value;
i++;
});
url += tmp;
}
$.ajax({
type: method.toUpperCase(),
url: url,
data: JSON.stringify(body),
dataType: "JSON",
contentType: "application/json",
success: function (result) {
if (callback !== null && callback !== "undefined") {
callback(result);
}
}
});
}
错误说xml解析错误,这是问题吗?我已定义JSON为返回类型,所以我不知道。
胡子哥哥
慕森王
相关分类