IE7 form submit problem

G

gzannd

I have a problem with submitting a form to a PHP page through a
dynamically created IFRAME in IE7. This code works fine in Firefox.
However, IE7 submits an empty form--the correct PHP page is called, but
no form variables are passed to the page.

Here's the client-side code:

//Create or reuse an IFRAME to submit data to a specified page.
//commandToken: A string that tells the page what to do.
//data: Data that the page will work with.
//callbackFunctionName: Name of javascript function to call when the
page returns.
//userID: ID of user.
//url: Page to which form will be submitted.
//iFrame: Name or reference of IFRAME through which the form data will
be submitted.
GenericWindow.prototype.executeServerRequest2 = function(commandToken,
data, callbackFunctionName, userID, url, iFrame)
{
var theIFRAME = null;

//If the specified IFRAME is a string then create the new IFRAME
element.
if(iFrame.length)
{
theIFRAME = this.createDataExchangeIFrame2(iFrame);
}
else
{
theIFRAME = iFrame;
}

if(callbackFunctionName != null)
{
if(!url)
{
url = serverURL;
}
else
{
url = serverURLBase + url;
}

var htmlString = "<html><body onLoad=''>";
htmlString += '<form action="' + url + '" id="submitForm"
name="submitForm" method="post">';
htmlString +='<input type="hidden" id="USERID" name="USERID" value="'
+ userID + '">';
htmlString +='<input type="hidden" id="DATA" name="DATA" value="' +
data + '">';
htmlString +='<input type="hidden" id="COMMAND" name="COMMAND"
value="' + commandToken + '">';
htmlString +='<input type="hidden" id="CALLBACK" name="CALLBACK"
value="window.parent.bbsRenderer.getWindow(&quot;' + this._windowName +
'&quot;).' + callbackFunctionName + '()">';
htmlString +='<input type="hidden" id="AUTHENTICATION_TOKEN"
name="AUTHENTICATION_TOKEN" value="' +
document.getElementById("AUTHORIZATION_TOKEN").value + '">';
htmlString +='</form>';
htmlString +='</body></html>';

this.logCommand(commandToken, htmlString);

if(theIFRAME.contentDocument)
{
//For Mozilla and similar browsers.
theIFRAME.contentDocument.write(htmlString);
theIFRAME.contentDocument.getElementById("submitForm").submit();
}
else if(theIFRAME.document)
{
//For IE and similar browsers.
document.frames[theIFRAME.id].document.write(htmlString);
document.frames[theIFRAME.id].document.forms[0].submit();
}
}

return theIFRAME;
}

/*Creates the IFRAME used to communicate between the window and the
server.
If the IFRAME already exists, then it will be reused.*/
GenericWindow.prototype.createDataExchangeIFrame2 = function(iFrameID)
{
var iFrame = document.getElementById(iFrameID);
if(iFrame != null)
{
return iFrame;
}
else
{
iFrame = document.createElement("IFRAME");

if(iFrameID == null)
{
iFrame.id = this._windowName + "_DataExchangeIFrame_" +
this._dataExchangeIFrameList.length;
}
else
{
iFrame.id = iFrameID;
}

this._windowFrame.appendChild(iFrame);
this._dataExchangeIFrameList[this._dataExchangeIFrameList.length] =
iFrame;
iFrame.src = "blank.html";

return iFrame;
}
}


Here's the server-side code:
$userID = $_POST['USERID']; //Calling process's user ID. The value
must be numeric and not null.
$data = $_POST['DATA']; //Calling process's data.
$callback = $_POST['CALLBACK']; //Calling process's callback
information.
$commandToken = $_POST['COMMAND']; //Calling process's command token.
This value is required.
$authenticationToken = $_POST['AUTHENTICATION_TOKEN']; //Calling
process's authentication token, used to verify sessions.

Result of a call in Firefox (I used PHPINFO() to dump the request and
post variables):
_REQUEST["USERID"] null
_REQUEST["DATA"] <GET_ROOM_DESCRIPTION roomID=\'2\' userID=\'0\'/>
_REQUEST["COMMAND"] GET_ROOM_DESCRIPTION
_REQUEST["CALLBACK"] window.parent.bbsRenderer.getWindow(\"LoginWindow\").handleGetDataResponse()
_REQUEST["AUTHENTICATION_TOKEN"] no value
_POST["USERID"] null
_POST["DATA"] <GET_ROOM_DESCRIPTION roomID=\'2\' userID=\'0\'/>
_POST["COMMAND"] GET_ROOM_DESCRIPTION
_POST["CALLBACK"] window.parent.bbsRenderer.getWindow(\"LoginWindow\").handleGetDataResponse()
_POST["AUTHENTICATION_TOKEN"] no value

The same call with the same data values produces no request or post
variables from IE.

Any help would be appreciated!
 
G

gzannd

I rebooted the computer, and the problem seems to have gone away...

I have a problem with submitting a form to a PHP page through a
dynamically created IFRAME in IE7. This code works fine in Firefox.
However, IE7 submits an empty form--the correct PHP page is called, but
no form variables are passed to the page.

Here's the client-side code:

//Create or reuse an IFRAME to submit data to a specified page.
//commandToken: A string that tells the page what to do.
//data: Data that the page will work with.
//callbackFunctionName: Name of javascript function to call when the
page returns.
//userID: ID of user.
//url: Page to which form will be submitted.
//iFrame: Name or reference of IFRAME through which the form data will
be submitted.
GenericWindow.prototype.executeServerRequest2 = function(commandToken,
data, callbackFunctionName, userID, url, iFrame)
{
var theIFRAME = null;

//If the specified IFRAME is a string then create the new IFRAME
element.
if(iFrame.length)
{
theIFRAME = this.createDataExchangeIFrame2(iFrame);
}
else
{
theIFRAME = iFrame;
}

if(callbackFunctionName != null)
{
if(!url)
{
url = serverURL;
}
else
{
url = serverURLBase + url;
}

var htmlString = "<html><body onLoad=''>";
htmlString += '<form action="' + url + '" id="submitForm"
name="submitForm" method="post">';
htmlString +='<input type="hidden" id="USERID" name="USERID" value="'
+ userID + '">';
htmlString +='<input type="hidden" id="DATA" name="DATA" value="' +
data + '">';
htmlString +='<input type="hidden" id="COMMAND" name="COMMAND"
value="' + commandToken + '">';
htmlString +='<input type="hidden" id="CALLBACK" name="CALLBACK"
value="window.parent.bbsRenderer.getWindow(&quot;' + this._windowName +
'&quot;).' + callbackFunctionName + '()">';
htmlString +='<input type="hidden" id="AUTHENTICATION_TOKEN"
name="AUTHENTICATION_TOKEN" value="' +
document.getElementById("AUTHORIZATION_TOKEN").value + '">';
htmlString +='</form>';
htmlString +='</body></html>';

this.logCommand(commandToken, htmlString);

if(theIFRAME.contentDocument)
{
//For Mozilla and similar browsers.
theIFRAME.contentDocument.write(htmlString);
theIFRAME.contentDocument.getElementById("submitForm").submit();
}
else if(theIFRAME.document)
{
//For IE and similar browsers.
document.frames[theIFRAME.id].document.write(htmlString);
document.frames[theIFRAME.id].document.forms[0].submit();
}
}

return theIFRAME;

}/*Creates the IFRAME used to communicate between the window and the
server.
If the IFRAME already exists, then it will be reused.*/
GenericWindow.prototype.createDataExchangeIFrame2 = function(iFrameID)
{
var iFrame = document.getElementById(iFrameID);
if(iFrame != null)
{
return iFrame;
}
else
{
iFrame = document.createElement("IFRAME");

if(iFrameID == null)
{
iFrame.id = this._windowName + "_DataExchangeIFrame_" +
this._dataExchangeIFrameList.length;
}
else
{
iFrame.id = iFrameID;
}

this._windowFrame.appendChild(iFrame);
this._dataExchangeIFrameList[this._dataExchangeIFrameList.length] =
iFrame;
iFrame.src = "blank.html";

return iFrame;
}

}Here's the server-side code:
$userID = $_POST['USERID']; //Calling process's user ID. The value
must be numeric and not null.
$data = $_POST['DATA']; //Calling process's data.
$callback = $_POST['CALLBACK']; //Calling process's callback
information.
$commandToken = $_POST['COMMAND']; //Calling process's command token.
This value is required.
$authenticationToken = $_POST['AUTHENTICATION_TOKEN']; //Calling
process's authentication token, used to verify sessions.

Result of a call in Firefox (I used PHPINFO() to dump the request and
post variables):
_REQUEST["USERID"] null
_REQUEST["DATA"] <GET_ROOM_DESCRIPTION roomID=\'2\' userID=\'0\'/>
_REQUEST["COMMAND"] GET_ROOM_DESCRIPTION
_REQUEST["CALLBACK"] window.parent.bbsRenderer.getWindow(\"LoginWindow\").handleGetDataResponse()
_REQUEST["AUTHENTICATION_TOKEN"] no value
_POST["USERID"] null
_POST["DATA"] <GET_ROOM_DESCRIPTION roomID=\'2\' userID=\'0\'/>
_POST["COMMAND"] GET_ROOM_DESCRIPTION
_POST["CALLBACK"] window.parent.bbsRenderer.getWindow(\"LoginWindow\").handleGetDataResponse()
_POST["AUTHENTICATION_TOKEN"] no value

The same call with the same data values produces no request or post
variables from IE.

Any help would be appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top