By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

IE7 form submit problem

P: n/a
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").val ue + '">';
htmlString +='</form>';
htmlString +='</body></html>';

this.logCommand(commandToken, htmlString);

if(theIFRAME.contentDocument)
{
//For Mozilla and similar browsers.
theIFRAME.contentDocument.write(htmlString);
theIFRAME.contentDocument.getElementById("submitFo rm").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!

Dec 30 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I rebooted the computer, and the problem seems to have gone away...

On Dec 29, 9:16 pm, "gzannd" <gza...@gmail.comwrote:
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").val ue + '">';
htmlString +='</form>';
htmlString +='</body></html>';

this.logCommand(commandToken, htmlString);

if(theIFRAME.contentDocument)
{
//For Mozilla and similar browsers.
theIFRAME.contentDocument.write(htmlString);
theIFRAME.contentDocument.getElementById("submitFo rm").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!
Dec 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.