Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Javascript Alert Box - catch click

Posted on 2013-06-13
4
Medium Priority
?
333 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

972 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