我正在使用MVC3。 以下是我的控制器:
public ActionResult TRUnutilizedOwnership(string strGeo, string strVertical, int ? intMonth, int ? intFlag) {
if (strVertical == null) {
strVertical = "All";
}
if (strVertical == "All") {
intFlag = 1;
} else {
intFlag = 2;
}
if (intMonth == null) {
intMonth = 5;
}
TRUnutilizedOwnershipModel oTRUnutilizedOwnershipModel = new TRUnutilizedOwnershipModel();
TravelReadyCommonEntities objTRCommonEntities = new TravelReadyCommonEntities();
TRUnutilizedOwnershipEntities objTRUnutilizedOwnershipEntities = new TRUnutilizedOwnershipEntities();
try {
oTRUnutilizedOwnershipModel.lstGeoEntity = oTRUnutilizedOwnershipModel.GetGeoVertical(strGeo, intFlag);
if (strGeo == null) {
strGeo = oTRUnutilizedOwnershipModel.lstGeoEntity[0].Geo;
}
oTRUnutilizedOwnershipModel = oTRUnutilizedOwnershipModel.GetUnutilizedOwnership(strGeo, strVertical, intMonth, intFlag);
oTRUnutilizedOwnershipModel.lstGeoEntity = oTRUnutilizedOwnershipModel.GetGeoVertical(strGeo, intFlag);
oTRUnutilizedOwnershipModel.lstVerticalEntity = oTRUnutilizedOwnershipModel.GetGeoVerticalChange(strGeo, 2);
oTRUnutilizedOwnershipModel.lstMonthEntity = oTRUnutilizedOwnershipModel.GetMonth();
return View(oTRUnutilizedOwnershipModel);
} catch (Exception ex) {
ILogManager LogManager = new LogManager();
var frame = new StackFrame(0);
LogManager.CallLogging(frame, ex.Message, ex.StackTrace);
return RedirectToAction("Error", "Common");
}
}
我正在使用以下jQuery,
function Dispalymaingrid() {
var Geo = $('#ddlGeo').val();
var Vertical = $('#ddlVertical').val();
var Month = $('#ddlMonth').val();
if (Vertical == "All") {
var Flag = 1;
} else {
var Flag = 2;
}
$.ajax({
url: "@Url.Action("
TRUnutilizedOwnership ", "
TravelReady ")",
datatype: "json",
type: "post",
data: {
strGeo: Geo,
strVertical: Vertical,
intMonth: Month,
intFlag: Flag
},
error: function () {},
success: function (result) {
debugger;
//return result;
}
});
}
当我从下拉列表中选择一些选项时,我的视图页面将显示默认,然后点击提交按钮。必须使用结果值更新表数据。
我必须在jQuery的成功函数中给出什么(只有Table内容应该更新)?
答案 0 :(得分:0)
这不是足够的信息,但我可以先告诉您应该调试控制器的响应:
$.ajax({
url: "@Url.Action("
TRUnutilizedOwnership ", "
TravelReady ")",
datatype: "json",
type: "post",
data: {
strGeo: Geo,
strVertical: Vertical,
intMonth: Month,
intFlag: Flag
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
// display error ?
},
success: function (resp) {
console.log(resp);
// update the table with resp here, e.g: $('.defaulttable').html(resp) ?
}
});
明智地使用Firebug或Chrome开发工具中的控制台。希望这会有所帮助。