我想要一個變量傳遞給我的JsonResult但她得到NUL所以這裏是從我的JsonResult和jQuery我的代碼難度在MVC 4使用JSON用ajax
[HttpPost]
public JsonResult MostraTela(Teste testea)
{
return Json(new { success = true });
}
和:
var testea = JSON.stringify(dado);
$.ajax({
url: '/Home/MostraTela',
type: 'POST',
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: {testea: testea },
success: function (data) {
alert(data.success);
},
error: function() {
alert("error");
},
});
Agora eu fui tentar passar uma model e esta esta recebendo nulo novamente alguma ideia do que pode ser? 我加緊數據:{testea:testea},錯誤,如果我踩到數據:testea,一切都在我的JsonResult自帶空
我的模型:
public class Teste
{
public int idteste { get; set; }
public string name { get; set; }
public int age { get; set; }
public string birthday { get; set; }
public string salary { get; set; }
}
謝謝工作* - * – user2004932
@ user2004932沒有問題,但爲什麼你不接受答案? – mattytommo
我接受了答案,你對這個新問題有了新的答案? – user2004932