所以我有两个有效的控制器方法:
[HttpGet]
public ActionResult EditWork(string work)
{
// do the bla bla
return Json(new {Success = true});
}
[HttpPost]
public ActionResult EditWork(WorkObjet work)
{
// Do the bla bla!
var listWork = TempData.Peek("myWorks") as List<WorkObjet>;
// Edit the value of the correct work object.
return Json(new {Success = true});
}
他们通过这样的Javascript调用:
function EditWork(event, anc) {
event.preventDefault();
var param = anc.attributes["data-id"].nodeValue;
$.ajax({
type: 'GET',
url: @Url.Action("EditWork", "Work"),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: { work: param }
}).done(function (data) {
if (data.Success === true) {
// Update the fields
} else {
console.log("Error:" + param);
}
}).fail(function (xhr) {
console.log(xhr.responseText);
});
}
function SaveEdit(){
var myWork = GetMyWork() // calls the field via jQuery
$.ajax({
type: 'POST',
url: @Url.Action("EditWork", "Work"),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({ work: myWork })
}).done(function (data) {
if (data.Success === true) {
// reload the page?
windows.location.reload();
} else {
console.log("Error:" + param);
}
}).fail(function (xhr) {
console.log(xhr.responseText);
});
}
他们的工作非常好。那么让我们做以下几点:
第七步怎么可能?
答案 0 :(得分:1)