Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

AJAX Newbie: load page with form

Thread view: 
boanator@gmail.com - 07 Feb 2006 18:55 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.