---
title: "How to Add Callback method & redirect to a page in Jquery?"  
description: "How to Add Callback method & redirect to a page in Jquery?"  
author: "Anonymous User"  
published: 2014-12-11  
updated: 2014-12-12  
canonical: https://www.mindstick.com/forum/12786/how-to-add-callback-method-redirect-to-a-page-in-jquery  
category: "asp.net"  
tags: ["c#", "jquery"]  
reading_time: 2 minutes  

---

# How to Add Callback method & redirect to a page in Jquery?

I have a [function in JQuery](https://www.mindstick.com/forum/157818/what-is-the-purpose-of-the-each-function-in-jquery-explain-with-an-example) which shows the Message in div to the User on the [ASPX page](https://www.mindstick.com/forum/218/how-do-i-create-an-aspx-page-that-periodically-refreshes-itself) at the top of the page. All [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why) just i want to [redirect](https://www.mindstick.com/forum/2005/radio-button-redirect) user to the URL that is passed in the function using [Callback](https://www.mindstick.com/articles/152/using-the-callback)'jquery.

As their is fadeOut() to show the div i need to redirect only when the fadeOut() effect or the [animation](https://www.mindstick.com/articles/13040/seven-helpful-tips-to-start-and-grow-an-animation-video-company) is completed. and not sudden display of div.

**[Javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-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](https://www.mindstick.com/interview/463/what-are-session-timeout-and-application-timeout-where-we-have-to-do-this-process)...!')</script>");

Here, i want to pass one more [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) to redirect to the said url using jquery only after the messabe is being displayed(animation completed).

Help appreciated!

## Replies

### Reply by Royce Roy

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;};
```

### Reply by Anonymous User

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;};
```


---

Original Source: https://www.mindstick.com/forum/12786/how-to-add-callback-method-redirect-to-a-page-in-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
