I am using asp.net, JavaScript and HTML Handler.
In a asp button onclick event I am calling the JavaScript like this.
<asp:Button ID="btn_Tagging" CssClass="button" UseSubmitBehavior="false"
     Text="Done" OnClientClick="DoneClick()" />
In the same page within the script tag I have written the JavaScript like this:
<script type="text/javascript">
function DoneClick()
{
   var checkLocation = "";
   var txtMM = document.getElementById("hdn_Tagging").value;///Id s of textbox assigned in code behind MB--
   txtMM = txtMM.slice(0, -1);
   var arrTxtMM = txtMM.split(",");
   for(var j=0;j<arrTxtMM.length;j++)
   {
      var Loc = document.getElementById(arrTxtMM[j]).value;
      if(Loc == "")
      {
         checkLocation = "";
         break;
      }
      else
      {
         checkLocation += Loc + ":";
      }
   }
   if(checkLocation != "")
   {
      var url ='Handler/newExifDetails.ashx?Id='+txtMM+'&Location='+checkLocation+'';
      var completetbl, html;
      $.getJSON(url,function(json)
      {
         $.each(json,function(i,weed)
         {
            var res = weed.res;
            alert(res);
            if(res == null)
            {
            }
            else
            {   
               window.top.location.href = "Dashboard.aspx";
            }
          });        
       });
    }
    else
    {
       alert("Please pick the locations for all objects");
    }
 }
</script>
Then when I click on button the alert within the JavaScript shows only if I put a breakpoint in Firebug or in Chrome Developers tool Script if I put breakpoint it works. Without putting that breakpoint neither the alert shows nor redirects.
 
     
     
     
    