Ajax request triggers pop-up blocker. Why?

Is it common for an Ajax post-method request to trigger the browser's popup blocker if the Ajax response handling function submits a form to a target window that does not yet exist?

The Ajax request is directed to the same web server as the original page.

Does anybody have a suggestion for a work-around?

A snippet from the function that makes the request is as follows:

var url ="/SomeServerPage.jsp";

var key = somekey.value;

var parameters ="key=" + key;

ajaxReq.open('POST', url,true);

ajaxReq.setRequestHeader("Content-type","application/x-www-form-urlencoded");

ajaxReq.setRequestHeader("Content-length", parameters.length);

ajaxReq.setRequestHeader("Connection","close");

ajaxReq.send(parameters);

A snippet from the function that deals with the response is as follows:

if (ajaxReq.readyState == 4)

{

if (ajaxReq.status == 200)

{

var entries = ajaxReq.responseXML.getElementsByTagName("entry");

var entry = entries[0];

var FormHtml = entry.getElementsByTagName("formHtml")[0].firstChild.data;

ajaxReq =null;

// Dynamically add the form to the HTML page

var newdiv = document.createElement("div");

document.body.appendChild(newdiv);

newdiv.innerHTML = FormHtml;

// Form name is "myForm"

// target name is "_someTarget"

myForm.submit();

// Dynamically remove the form

document.body.removeChild(document.body.lastChild);

[2101 byte] By [sun3sweeta] at [2007-11-27 2:32:46]
# 1

I figured this out. Thanks anyway. To avoid attracting the popup blocker's attention, apparently a new window can only be opened as a result of the user's direct interaction, pretty much.

The solution was to create a new, empty window BEFORE firing off the Ajax request/response. Then during the Ajax response processing I can target the new window to receive the response to the first window's form action.

sun3sweeta at 2007-7-12 2:48:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Hi,

Depending on your application, another way to deal with the POST's response is to show the user a "DIV" in page. This way the user doesn't have to see another browser instance pop up. Some user my find instances of browsers popping up annoying. But is does depend on the targeted user experience...

Hope this helps...

Thanks - Mark

markbaslera at 2007-7-12 2:48:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...