window.open causing ajax problems

hi,

I have the following line of code:

$.ajax({url:"case.php",type:"post"});

window.open("test.php","_self");

The case.php assigns a value to a session variable, it works perfect until I add the window.open statement, then the ajax statement stop working. Any idea?
LVL 1
joyacv2Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GaryConnect With a Mentor Commented:
Because the ajax is asynchronous ergo you are changing the url before it is finished

Change your code to
$.ajax({ url: "case.php",type:"post"}).done(function () {
    window.open("test.php","_self");
})

Open in new window

0
All Courses

From novice to tech pro — start learning today.