Solved

Javascript Alert Box - catch click

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
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.…

757 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

21 Experts available now in Live!

Get 1:1 Help Now