這裏是jQuery代碼:jQuery的POST方法不起作用
$(function() {
$("#personCreate").click(function() {
var person = getPerson();
// poor man's validation
if (person == null) {
alert("Specify a name please!");
return;
}
// take the data and post it via json
$.post("banner/save", person, function (data) {
// get the result and do some magic with it
alert("Post");
var message = data.Message;
$("#resultMessage").html(message);
});
});
});
控制器:
[HttpPost]
public ActionResult Save(PersonModel person)
{
string message = string.Format("Created {0} in the system",person.Name);
return Json(new PersonViewModel {Message = message });
}
當我按一下按鈕沒有任何行動。該帖子從不指向控制器。
使用'$(函數(){})'是'$(文件)。就緒的快捷方式()' – lonesomeday 2011-05-28 14:08:26
我感謝名單不知道! :) – 2011-05-28 14:09:29