Javascript confirm window wont go away -


i can't seem find answer where, feel might browser specific (i'm using chrome). how come when click cancel on confirm window keeps popping right up?

<script> $(document).ready(function() { $('.postdelete').click(function () {     var c = confirm("please confirm post deletion");     if (c == true) {         var post = $(event.target).closest('.post');         var postid = post.find('.postid').html();         //send postid deletepost.cshtml execute sql delete command         $.ajax({             url: '../deletepost.cshtml',             type: 'get',             data: { selectedpostid: postid },             success: function (result) {                 window.location.replace(window.location.href);                 console.log("result: " + result);             }         });     }     else { console.log('canceled');} }); }); </script>  

since not code causing problem must in html here is: _layout.cshtml

 @{  }  <!doctype html>  <html lang="en"> <head>     <meta charset="utf-8" />     <title>@page.title</title>     <link rel="stylesheet" type="text/css" href="~/shared/template.css" />      <!--jquery cdn-->     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> </head>   <body>       <div id="header">          <div id="signin">                   click me sign in              <img id="bipolarchar" src="~/resources/images/bipolarchar.png" alt="bipolar sign in guy" />             <div id="signinform">                  @renderpage("~/account/_login.cshtml")             </div>         </div>         <div id="headerslogan">@page.title</div>     </div>      <div id="navigation">@renderpage("~/shared/_navigation.cshtml")</div>      <div id="maincontent"> @renderbody()</div>     <div id="footer">         <br />         <span><i>website designed jamie horton</i></span>         <br /> <br />         <span><i>last updated: @(datetime.now)</i></span>         @renderpage("~/shared/_google_analytics.cshtml")     </div>      <!--jquery-->       <script>         $(document).ready(function () {             console.log('wtf going on');             @if (websecurity.currentusername != "anonymous" & !string.isnullorempty(websecurity.currentusername) & websecurity.userexists(websecurity.currentusername) & websecurity.isauthenticated)             {                 <text>                 $('.postauthorized').show();                 console.log('show dam things');                 </text>             }             else             {                 <text>                 $('.postauthorized').hide();//hide authorized post icons                 console.log('hide dam things');                 </text>             }         });         </script>      <!--signin form show/hide-->     @renderpage("~/shared/_signinform.cshtml")     <!--resize posts-->     @renderpage("~/shared/_resizeposts.cshtml") </body> </html> 

this page i'm on trying delete post:

  @{     layout = "~/shared/_layout.cshtml";     page.title = "notes page";      var db = database.open("startersite");     try     {          var pageposts = db.query("select * posts page='notes' order date desc ;");         <div class="posts">             @foreach (var post in pageposts)             {                 @renderpage("~/shared/_posts.cshtml",            new            {                author = post.author,                content = post.content,                date = post.date,                title = post.title,                id = post.id            })             }         </div>     }     catch { <h1>sorry have reached maximum connection limit database. please try again. </h1>} }    @renderpage("~/shared/_resizeposts.cshtml") 

this _post portion:

     @{         <div class="post" id="@pagedata["id"]">              <div class="posttitle">@pagedata["title"]<span class="postid">@pagedata["id"]</span></div>             <div class="postauthorized">                 <div class="postedit">edit</div>                 <div class="postdelete">del</div>             </div>             <div class="postbyline">                 <span class="postauthor">@pagedata["author"]</span> on                 <span class="postdate">@pagedata["date"]</span>             </div>              <div class="postcontent">                 @pagedata["content"]              </div>         </div>          <script>     $(document).ready(function() {         $('.postdelete').click(function () {             var c = confirm("please confirm post deletion");             if (c == true) {                 var post = $(event.target).closest('.post');                 var postid = post.find('.postid').html();                 //send postid deletepost.cshtml execute sql delete command                 $.ajax({                     url: '../deletepost.cshtml',                     type: 'get',                     data: { selectedpostid: postid },                     success: function (result) {                         window.location.replace(window.location.href);                         console.log("result: " + result);                     }                 });             }             else { console.log('canceled');}         });     });         </script>      } 

and here deletepost.cshtml

@functions{     public bool deletepost()     {         var db = database.open("startersite");         var postid = request["selectedpostid"];         var cmd = "delete posts id=" + postid + ";";         try {             //db.execute(cmd);             return true;         }         catch (exception er)         {              er.tostring();         }         return false;     } }   @deletepost();  


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -