Search code examples
javascriptajaxwindow.open

window.open when ajax call end, doesn't work


i'm doing and Ajax call to send parameters to one .php file, when the call is done, i want to popup a new window to the results page, but it doesn't work.

here is my ajax code

        $.ajax({
            type: "POST",
            url: "pipeline2.php",
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            //async: false,
        }).done(function (data) {
            $("#resultados_pipeline").append(data);
            document.getElementById('Running').style.display = 'none';
            window.open("results_page.php?jid="+job_id);
            alert(job_id);
        });

i first think that maybe the job_id is not set in ajax, but the alert show me the expected...

i also tried with the async: true, and it doesn't work either


Solution

  • Browsers don't allow window.open calls except when involved from a user triggered event.

    An Ajax response event is not something triggered by the user, so popups are blocked at that point.