的目的:
更改我的$。員額到$就以syncronize它,直到要求完成顯示的消息。
我想知道我究竟是如何能做到這一點有一個Ajax請求,我的大問題是,當我嘗試更換DIV內容,我所使用.post的$
代碼在這裏做到了:
視圖
function NewVersion() {
$.ajax({
url: "/Valoration/NewVersion",
type: "POST",
async: false,
success: function (data, status, xhr) {
if (data.success) {
$.post(data.hvmHeaderPartialView, function (partial) { $('#divHvmHeader').html(partial); });
MessageNewVersionSucced();
}
},
error: function (xhr, status, err) {
alert(err);
}
});
控制器
public ActionResult HvmHeaderPartialView()
{
return PartialView("_HvmHeaderPartialView,", DetailHvmModel);
}
private ActionResult NewVersion()
{
var result = hvmService.addNewVersion(hvm);
var HvmHeaderPartialView = Url.Action("HvmHeaderPartialView,");
return Json(new
{
success = result,
hvmHeaderPartialView= HvmHeaderPartialView,
});
}
是的,我需要async = false – user1520494
@ user1520494得到它,只是好奇,是什麼原因? – Ulises
你好Ulises! ty爲您的響應,我需要Async = false,因爲我不想在$ .post完成之前顯示MessageNewVersionSucced() – user1520494