AJAX Newbie: load page with form

B

boanator

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.
 
B

boanator

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.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top