jquery - not able to redirect using javascript -


i want redirect using javascript , able redirect using document.write() otherwise not.

document.write("you redirected main page in 5 sec."); settimeout(redirect_admin(), 5 * 1000); 

i want redirect page without using document .write() entire code:

$(document).ready(function () {     btnsubmit = $("#btnlogin");      btnsubmit.click(function () {         //$("#preloader").show();         //$("#status").show();         var uname = $("#username").val();         var upass = $("#pasword").val();         var str = -1;         $.ajax({             type: "post",             async: false,             url: "default.aspx/userlogin",             data: '{"username":"' + uname + '","userpassword":"' + upass + '"}',             contenttype: "application/json; charset=utf-8",             datatype: "json",             success: function (response) {                 str1 = response.d;                 //$('#status').delay(300).fadeout(); // first fade out loading animation                 //$('#preloader').delay(350).fadeout('slow');                 str = str1;             },              failure: function (msg) {                 bootbox.alert("please contact administrator");             }         });         redirectuser(str);     })       redirectuser = function (str) {        if(str == 1){}        ....        else if(str ==6) {           document.write("you redirected main page in 5 sec.");             settimeout(redirect_admin, 5 * 1000);         }         function redirect_admin() {         var nexturl = location.protocol + "//" + location.host + "/adminhome.aspx";         window.location = nexturl;     } 

don't use () next function name.

settimeout(redirect_admin, 5 * 1000); 

hope helps:)

adding that, not sure in way document.write stopping getting things working. can use modal or ajax-loader or alert instead of document.write. if mean.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -