jquery - MVC Calling ActionResult Method from JavaScript -
i'm calling actionresult controller method javascript function on view. function works fine, actionresult controller method runs fine final line supposed move different view not happen. can step through lines of code on new view after steps through lines on new view original view still displayed. use of $.get() call correct? or should using other jquery method call controller. don't need return controller in instance, run database code , move new view.
controller:
if (modelstate.isvalid) { system.web.security.membershipuser user = membership.getuser(); var job = (from j in db.jobs j.id == id select j).first(); job.drivermembershipusername = user.username.tostring(); job.jobstatus = "purchased"; viewbag.purchasemessage = "thank purchasing job."; db.entry(job).state = entitystate.modified; db.savechanges(); return view("jobdetail", job); }
javascript call original view page:
var url = "/job/purchasejobfinalize/" + jobid; $.get(url, function () { });
consider using
@html.actionlink("purchasejobfinalize", "job", new { jobid: jobid});
what using now, async call server, , it'll return rendered html of view.
you can take result of call , put div, way moving spa (single page app) space.
or can try this
window.location = "/job/purchasejobfinalize/" + jobid;
or can try
window.location.assign("/job/purchasejobfinalize/" + jobid)
Comments
Post a Comment