Solved

Javascript Alert Box - catch click

Posted on 2013-06-13
4
323 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
align Linkedin sign to the right page 5 37
Javascript_Set_dropdown_value 7 34
Jquery 10 20
Html form and modal / img src -problem 3 12
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

832 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