Javascript Alert Box - catch click


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},
                function(jqXHR, textStatus, errorThrown) {
            function(jqXHR, textStatus, errorThrown) {
    				alert("Success"); << ONCLICK of Alert... location.reload(); >>
                    if($('#inspect-modal').data('modal').isShown == true) {
    location.reload(); <<remove this>>

Open in new window

Who is Participating?
WalterRRConnect With a Mentor Author Commented:
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!
WalterRRAuthor Commented:
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?

WalterRRAuthor Commented:
the solution
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.