This discussion is archived
3 Replies Latest reply: Jun 16, 2009 4:23 AM by 843833 RSS

Ajax request triggers pop-up blocker.  Why?

843833 Newbie
Currently Being Moderated
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);