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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -