私のmvcアプリケーションでjqueryのajaxメソッドを使用してフォームを送信しようとしています。 dataTypeをjsonに、contentTypeを "application/json; charset = utf-8"に設定しました。私のコントローラのアクションでは、私はJsonResultを返しています。.NET/MVC保存するダイアログボックスがJSON応答で開きます
何らかの理由で、JSON応答が正しく処理されず、その代わりにJSONオブジェクトを含むファイルを保存するダイアログボックスが表示されます。私のコントローラのアクションで
$(document).ready(function() {
$("#editPageContentForm").submit(function() {
$.ajax(
{
type: "POST",
dataType: "json",
url: $("#editPageContentForm").attr("action"),
contentType: "application/json; charset=utf-8",
data: { ID: $("#id").val(), small_title: $("#small_title").val(), big_title: $("#big_title").val(), body: $("#body").val(), subheading: $("#subheading").val() },
success: function(result) {
alert('hi');
},
error: function(req, status, error) {
alert("Sorry! We could not receive your feedback at this time.");
}
}
);
})
、私は何かに似てい:なぜ応答はJSONとして戻って来ていません
public JsonResult Edit(int id, string small_title, string big_title, string subheading, string body)
{
return Json(new {success = true, message = "success"});
}
を?
はい、それは私のために働いた! – Nima
それはなぜうまくいくのでしょうか? – SoftwareSavant