Solved

window.open causing ajax problems

Posted on 2014-03-24
1
507 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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)

821 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