Solved

window.open causing ajax problems

Posted on 2014-03-24
1
503 Views
Last Modified: 2014-03-24
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?
0
Comment
Question by:joyacv2
1 Comment
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39950884
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

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

863 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

23 Experts available now in Live!

Get 1:1 Help Now