I am trying to use ajax to load a page that has a <form> element.
Here is my problem: if the page being loaded has a <form> element, it
will only work in Internet Explorer. In Netscape, anything that is
inside the <form> element will not be loaded into my main page.
Has anyone had this problem? I would greatly appreciate any advice or
information that will lead me to a solution.
The following is a basic example of how I load the page:
<html>
...
<script>
var httpRequest;
function loadPage() {
var url = "formTest.jsp"
if (window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
httpRequest = new XMLHttpRequest();
}
httpRequest.opem("GET", url, true);
httpRequest.onreadystatechange = function() {processRequest(); };
httpRequest.send(null);
}
function processRequest() {
if (httpRequest.readyState == 4) {
var contentViewer = document.getElementById("contentViewer");
if (httpRequest.status == 200) {
contentViewer.innerHTML = httpRequest.responseText;
} else {
contentViewer.innerHTML = "Error: cannot load page...";
}
}
...
</script>
...
</html>
Thanks in advance.
Ingo R. Homann - 08 Feb 2006 11:07 GMT
Hi boanator,
Did you never hear of "copy&paste"? Or is this bug really in your sources?:
> httpRequest.opem("GET", url, true);
Ciao,
Ingo
boanator@gmail.com - 08 Feb 2006 14:32 GMT
If that bug was really in my source and it still worked in IE, then I
would actually have to give some props to Bill Gates. I was trying to
make the code readable in this post.
Anyway, I figured out what I was doing wrong and it had nothing to do
with the code that I posted. It turns out my problem was in
formTest.jsp.
In formTest.jsp, I had a <table> element with a <form> element inside
like so:
<table>
<form>
<tr><td>...</td></tr>
...
</form>
</table>
This would work just fine in any browser if I was just requesting
"formTest.jsp". When I used XMLHttpRequest to load "formTest.jsp" into
another page, it would only work in Internet Explorer.
My solution was:
<form>
<table>
<tr><td>...</td></tr>
...
</table>
</form>
So far this has worked in all browsers. Thanks for taking the time to
read my post.