0

NetworkErrorjQuery Ajax を使用して WebAPI を呼び出そうとすると、以下のコードが返される理由を教えてください。Web メソッドは正常に呼び出されましたが、返された後にエラーが発生しました。

HttpGet へのアクセスを変更すると、IE を使用して Web メソッドにアクセスできます。

したがって、jQuery Ajax に何か問題があるに違いありません。誰かが助けてくれることを願っています。

$.ajax({
type: "POST",
async: false,
url: "http://localhost:5000/API/Test",
xhrFields: { withCredentials: true },
data: JSON.stringify(Params),
contentType: "application/x-www-form-urlencoded",
success: function (msg) {
},
error: function (XHR, errStatus, errorThrown) {
});

[Route("API/Test"), HttpPost]
public string Test()
{
JsonConvert.SerializeObject(new { Test = "Test Message" });
}
4

2 に答える 2