0
I持って問題試してみて、ピンポイントするために簡略化され、次のAJAX呼び出し、:しかしAJAXはnullを返します
[HttpPost]
public ActionResult submitForm(string json)
{
System.Diagnostics.Debug.WriteLine("made it here");
var check = System.Web.Helpers.Json.Decode(json);
System.Diagnostics.Debug.WriteLine(check);
System.Diagnostics.Debug.WriteLine(check.glbBlue);
return View();
}
:これは、次のメソッドを呼び出す
$('#userUpdateForm').submit(function (e) {
$.ajax({
type: "POST",
url: '@Url.Action("submitForm", "Home")',
data: JSON.stringify({
'blue': window.glbBlue,
'eg2': 'eg3'
}),
contentType: "application/json; charset=utf-8",
success: function (result) {
alert("Success");
},
error: function (result) {
alert("A problem occured when submitting the form.");
}
});
e.preventDefault();
});
をコントローラが受け取るJSONはnullです。なぜこれが起こるのですか?私はブラウザに要求ペイロードがあり、私が期待している値があることがわかります。 'Window.glbBlue'はグローバル値で、アラートがその値をチェックするために使用されたときに正しく設定されていることもわかっています。
おかげで、私のためにそれを修正! – peanut
大歓迎です。@ user3316147 – Ashiquzzaman