Thursday, 15 May 2014

jquery - Why doesnot page get redirected? -



jquery - Why doesnot page get redirected? -

i have called delete controller ajax. info deleted , success function executed page not redirected new page mentioned in controller. here ajax code:

function deletex(ids) { var x={id:ids}; var a=confirm("are sure delete info of id"+x["id"]); if(a==true) { $.ajax({ type: "post", url: "delete", data: x, datatype:"html", success: function (data) { set(data); alert("data deleted"); }, error: function e() { alert("error"); } }); } else alert("you cancelled it"); }

my controller:

[httppost] public actionresult delete(long id) { country country = db.countries.find(id); db.countries.remove(country); db.savechanges(); homecoming redirecttoaction("create","countries"); }

the right way have been, homecoming json object frm delete controller indicate if delete successfull or not , ajax's success method, depending on value of returned json object, redirect action of choice.

jquery ajax asp.net-mvc

No comments:

Post a Comment