Home > DeveloperSection > Forums > How to Add Callback method & redirect to a page in Jquery?
Alex Leblois
Alex Leblois

Total Post:67

Points:471
Posted on    December-11-2014 10:33 PM

 ASP.Net C#  JQuery 
Ratings:


 2 Reply(s)
 598  View(s)
Rate this:

I have a function in JQuery which shows the Message in div to the User on the ASPX page at the top of the page. All works fine just i want to redirect user to the URL that is passed in the function using Callback'jquery.

 

As their is fadeOut() to show the div i need to redirect only when the fadeOut() effect or the animation is completed. and not sudden display of div.

 

Javascript:

 

function ShowJPopupTitleCallBack(msg, msgTitle) {

    $("#jDialogMessage").html(msg);

    $("#jDialogMessage").show("slow", function() {

 

    });

    $("#jDialogMessage").fadeOut(5000);

//window.location="Login.aspx";

    return false;

};

In aspx.cs file:

 

Page.ClientScript.RegisterStartupScript(this.GetType(), "Popup", "<script type='text/javascript'>ShowJPopupTitleCallBack('Sorry! Your session has being expired please login & try again.','Session Timeout...!')</script>");

Here, i want to pass one more parameter to redirect to the said url using jquery only after the messabe is being displayed(animation completed).

 

Help appreciated!



ben reitman
ben reitman

Total Post:96

Points:676
Posted on    December-12-2014 6:09 AM

pass the callback inside fadeout method

 

function ShowJPopupTitleCallBack(msg, msgTitle) {

    $("#jDialogMessage").html(msg);

    $("#jDialogMessage").show("slow", function() {

 

    });

    $("#jDialogMessage").fadeOut(5000,function(){

         window.location="Login.aspx";

    });

//window.location="Login.aspx";

    return false;

};


Royce Roy
Royce Roy

Total Post:134

Points:938
Posted on    December-12-2014 6:53 AM

You want the callback to show() to trigger the fadeOut(), then the callback in fadeOut() to perform the redirect...

 

function ShowJPopupTitleCallBack(msg, msgTitle) {

    var dialogMessage = $("#jDialogMessage");

    dialogMessage.html(msg);

    dialogMessage.show("slow", function() {

        dialogMessage.fadeOut(5000, function () {

            window.location="Login.aspx";

        });

    });

    return false;

};


Don't want to miss updates? Please click the below button!

Follow MindStick