Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firefox works, IE doesn't with identical code

Status
Not open for further replies.

old8man

Programmer
Nov 11, 2007
6
US
I have an ajax routine that I am using on two separate web pages for the same web site. It swaps two views of data. On page one both IE and Firefox process correctly. On page 2 firefox processes correctly but IE doesn't display the requested data, and to the best of my ability to determine, (which is highly suspect) doesn't initiate a valid get header request. In all four cases I am using identical javascript, and in the web page sections defining ajax elements (divs) and headings, identical structures. The only difference is the data sets. IE comes up with an "undefined error". Has anyone had this problem?
 
faq222-2244 will help explain. We can't see you code, or your URL, so can't tell you anything without more info.

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Perhaps I was not clear enough. I don't need people to debug the internals of my code. I am trying to understand the workings of IE7, and XMLHttpRequest.
1. I am using ajax in a web application. There are two separate web pages using identical javascript code, PHP code and associated HTML code (and I mean absolutely identical).
2. The application works perfectly on all pages using Firefox.
3. The application works on one of the pages using IE7.On the second page IE7 fails to post the result from the server to the web page. It receives the data, passes the status checks, and fails on the javascript statement: obj.innerHTML = xmlhttp.responseText.
4. A validation of the HTML code of both pages result in no errors. IE7 DOM is solid and identical to Firefox DOM. If I had some tool where I could step through the javascript of IE7 such as there is on Firefox, I could probably diagnose more, but I am at the limit of what I can see with the tools I have been able to find for IE7.
5. Does anyone have a workaround or a solution? Has anyone else encountered this problem?
 
It sounds like there is a problem in the code.

If one page works and the other doesn't then they aren't identical. You may think they are, but there will obviously be a reason why one page doesn't work.

Showing the code would probably yield a much better answer.

Let's draw an analogy.

I have 2 machines here, identical machines.
One works the other doesn't.
Can you tell me how the machine works so I can understand why machine number 2 doesn't function.

Difficult isn't it?

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
I'm sorry, but the code is identical.
The HTML code associated with the DIV containing the rotuine is an include file for both pages.
The javascrip file is the same .js file used by both pages
The php code is the same identical routine for both pages.
The DOM for both pages are well-formed and correct.
The pages do differ outside of the DIV's dealing with the AJAX, but both pages pass HTML checks for proper coding, and I have checked the DOM of each about 5 times to insure they are well-formed.

The OLNY difference is code is that for IE7:
xmlhttp = new ActiveXOblect("Msxml2.XMLHTTP");
and for firefox: xmlhttp = new XMLHttpRequest();

Both pages work consistently for Firefox. I can and have traced each variable and each outcome of each line of code using Firefox tools. IE7 works fine under the first page I pull up. but fails on the second page. The error is a wonderfully descriptive statement, "Unknown runtime error".

There are global state variables in the .js code which, if IE7 used the same instance of .js for both pages, might screw things up, but in theory I am bringing in a new instance with a new page call. Such is the case in Firefox. Also, there may some peculiarity with activeX that I don't understand, since I am weak in XML, but what?

I have to think that if the essential code works well for Firefox, I am dealing with some subtle issue in IE7, classed as an "unknown runtime error".

Thank you for your comments.
 
Is there a reason that you're not posting your code?

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B> bites again.[/small]
 
You don't hear me. I have told you the exact command that fails. It is:

obj.innerHTML = xmlhttp.responseText;

Based on javascript debugging in firefox, the obj is valid. There are absolutely no differences in code between Firefox and IE7 other that how the xmlhttp object is created, which I have shown you. If IE7 did not see a valid oject, its error message would by "object missing". I don't get that message. I get "Unknmown runtime error" which baffles me.

I have validated that the response text is actually received by IE7, but gets lost somewhere between there and the obj.

The object is obj=document.getElementById("productwin");
where the ID point to:
<div id="productwin" class="productwinclass"></div>

same code for all four cases, three of which work!
(two firefox, one IE7)
 
Either:

1) Paste a URL to the page in question
2) Provide the [!]complete[/!] (that's any HTML, javascript, css files regardless of whether you think they are irrelevant or not) code for the page

If you can't provide either of these, no one can or will help you. Simple as that.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Hey, at least we now know what the actual error message is.

That's the problem. It's a runtime error.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Finally think I have it solved. My thanks for your help. Your request for code drove me to try to create an unabiguous and completely self-contained snippet from a huge and complex page that could not be efficiently analized and commented upon without wasting time.

Will provide a wrapup when I have an iron-clad validation of the solution.
 
Have you tried alerting "obj" just to see what IE thinks it is?

If you could post a URL, I'd look through it with Visual Interdev - a great debugger for IE.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks, Dan. I have solved the problem. There was a misplaced </form> statement in the main page HTML code, buried in an include, and not reflected in the DOM mapping (Both IE7 and Firefox had identical mappings)

Your approach was right-on! I finally found the error by doing just what you suggested. I broke the obj.innerHTML=xmlhttp.responseText in two statements and aletred on the second statement, listing inData in the alert:

inData=xmlhttp.responseText;
obj.innerHTML=inData;

The "Unknown Runtime Error" occurred on the second statement, and I had a valid obj. The variable inData contained a form. So on the possibility I was importing a form into a form, I scanned the HTML source and found the coding error.

Interestingly enough, Firefox didn't care and handled the AJAX HTML code perfectly without a hickup. Apparently the Firefox logic can keep the two forms sorted out. IE7 it appears does not like a form within a form. It rejected the case but never said why. In any event, a form within a form is not very good form.

I think this is a great case showing how very subtle interactions between imported AJAX HTML code and the main page using different browsers can waste tons of programming time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top