model view controller - JSON If Confirm message ok , session clear than return to MainPage -
,hi all,
i have href exit
<a href="home/exit" id="exit-link">exit</a>
i trying show confirm message on click href.
İf confirm ok need go home/exit session out show index(mainpage)
however, confirm not work , ı can index page ı see index html(lots of texts)
<script> $(function () { $("#exit-link").on("click", function () { if (confirm("are sure want exit?")) { $.ajax({ url: "/home/exit", type: "post", datatype: "json", contenttype: 'application/json', success: function (mydata) { $("#page").html(mydata); }, error: function () { $("#page").html("fail"); } }); return false; } }); });
<div id="page"></div>
my exit actionresult
public actionresult exit(mymodel model) { int userid = convert.toint32(session["kullaniciid"]); // user id if (userid >= 1) { session.clear(); } var stringview = renderrazorviewtostring("index", model); return json(stringview, jsonrequestbehavior.allowget); }
function showmypopup() { if (confirm("are sure want exit?")) { $.ajax({ url: "/home/exit", type: "post", datatype: "json", contenttype: 'application/json', success: function (mydata) { $("#page").html(mydata); }, error: function () { $("#page").html("fail"); } }); }else return false; }
and should make call link
a href="#" id="exit-link" onclick="showmypopup()">exit
Comments
Post a Comment