Solved

Javascript Alert Box - catch click

Posted on 2013-06-13
4
322 Views
Last Modified: 2013-06-19
Hi

I would like to catch the click of an alert box and reload location at this point. Currently I have reload at the end of the function which is not the desired behaviour


function myFunction(url, myuser, myprocessing){
	
    var xhr = $.ajax({
        "url": url,
        "data": { creatio: myuser, reqiu : myprocessing},
        "error": 
                function(jqXHR, textStatus, errorThrown) {
        				alert(jqXHR.responseText);     			
                
        },
        "success": 
            function(jqXHR, textStatus, errorThrown) {
    				alert("Success"); << ONCLICK of Alert... location.reload(); >>
    				
                    if($('#inspect-modal').data('modal').isShown == true) {
                    	$('#inspect-modal').modal('hide');
                    }
                    
            
    }
});
    location.reload(); <<remove this>>
}

Open in new window

0
Comment
Question by:WalterRR
  • 3
4 Comments
 
LVL 22

Expert Comment

by:Mrunal
ID: 39246840
0
 

Author Comment

by:WalterRR
ID: 39246921
Thanks for the reply...

The reason i wasn't using  a Confirm() was this is just a success message back to the user. There will be nothing to cancel. If I have a confirm() i don't think I can have this without the cancel button?

Maybe I have no option in this case?

W
0
 

Accepted Solution

by:
WalterRR earned 0 total points
ID: 39248922
Fix is to move the reload after the Alert as this is synchronous. I must have had a typo the 1st time i tried this!
0
 

Author Closing Comment

by:WalterRR
ID: 39258796
the solution
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now