开发者

How to close the JQuery Dialog Box from the child page

I am using JQuery and C#.

I am opening a JQuery Modal Dialog on the click of login link. Then I submit the complete form and form action is changed to my /login.aspx page, for a 15 seconds I am showing ajax processing image and on login.aspx page I validate the username and password entered by user. There can be two scenario

1) User enters the valid username and password, in this case I am again redirecting back to same page from where the login link was clicked after validating on my /login.aspx page, this functionality is working fine as my current page is reloaded again.

2) however when user enters wrong username and password, I keep user on /login.aspx page (Please note I don't redirect back to the page from where user has clicked the login link). Now Issue is that when user enter wrong username and password then /login.aspx comes, however if user in between clicks the browser back button then my Dialog box is shown open as I have set timeout for 15 secs. I want to close the dailog box once user enters the开发者_如何学C wrong username and password.

Below is the Jquery code where I am opening the dialog box.

 $('#skywardsLogin').dialog({
                        autoOpen: true,
                        width: 450,
                        modal: true,
                        title: $('.LoginpopupHeaderText').text()
                    });

And here I am trying to submit the form and changing the form action and also I am given timeout for 15 secs for showing the ajax processing image.

$("#aspnetForm").attr("action", "http://localhost:8080/english/include/aspx/Login.aspx");
$("#aspnetForm").submit();
$('#divSuccessLogin').show();
// Wait for 15 seconds 
setTimeout(closeDialog, 15000); 

CloseDailog code is given below.

        function closeDialog()
        {
            $('#skywardsLogin').dialog("close"); 
}

I am struggling to close my dailog box as there is timeout for 15 secs to show the ajax processing image. please suggest


I agree with Gidon it's a bit confusing. But let's see if I understand you correctly, let's do it step by step.

  1. User comes to a page, let's say index.aspx.
  2. User clicks a link that opens a dialog (using $().dialog())
  3. In the new dialog the user put's in their username/password.
  4. When pressing a submit button you change en action of aspnetForm and submit the form.
  5. If the information is incorrect the user is still on login.aspx.
  6. User uses the browser's back-button
  7. What happens?

It's the last part I don't quite understand. If the user clicks on the back button doesn't they end up on index.aspx?

Also why the timer? There are no ajax calls? $("#aspnetForm").submit(); submits the form as a normal html form or are you using something to override jQuery's standard .submit()

In any case if you want to invoke something after an ajax call is completed don't use a timer use:

$(document).ajaxComplete(function() {
    $('#skywardsLogin').dialog("close"); 
});

Also it would be good if you could provide a link to the solution.

Are I'm on the right track?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜