i have this following jquery to load partial view in a div
var acc = this.id;
$('#details').load('/AccountAndTransaction/Grab', function (html)
{ $('#details')[0].value = html; });
and its working good , but now i want to pass ‘var acc’ with this load method , how can i achiev this??
controlller
[HttpGet]
public ActionResult Grab(string AccountNumber)
{
TermDepositAccountViewModel tdParent = new TermDepositAccountViewModel();
account ac = db.accounts.Single(u => u.accountNumber == AccountNumber);
deposittd td = db.deposittds.Single(u => u.accountNumber == AccountNumber);
tdParent.deposittd = td;
tdParent.account = ac;
return PartialView("TermDepositPartialView", tdParent);
}
You just need to pass the
accas part of the URL. Since you have named your parameter in the Action method asAccountNumberit should be in this format.if your parameter name is
idyou can have it in this format (as in the default route the optional parameter is mapped asid, it should be automatically handled)