943,723 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Aug 15th, 2008
0

Re: AJAX vs IE issue

Weird. I thought declaring variables in JavaScript was more of a "good practice" than a requirement. I always do it but wouldn't think that it would break the script.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Aug 15th, 2008
0

Re: AJAX vs IE issue

I agree, that is weird

If I understand correctly, declaring a var within a function block changes the scope of the variable from the global scope (window) to the local scope (function), thus avoids namespace collisions if you have like-variable names in the global scope. Maybe this is why it worked in my environment, I didn't have any other javascript on the page besides this function.

??? Glad you got it to work though !!!

:-)
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008
Aug 15th, 2008
0

Re: AJAX vs IE issue

Click to Expand / Collapse  Quote originally posted by Ciubhran ...
If I declare "var xmlHttp" as a global, it only works in FF. If I declare it inside of makePOSTRequest (like the above example), then it only works in IE.
I read that declaring it in the global scope (outside the function body) will produce errors if you try and reuse the xmlHttp object, so place it in your function and re-declare it as null for each use.

Did you change the values of your alertContents function from xmlHttp to this, when the xmlHttp is no longer in the global scope (when it is declared in the function)?

IF not your function might have trouble seeing those values ?

I'm tired, sorry I can't be of more help ... but it was working in all of my browsers earlier today.

G'night
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008
Aug 15th, 2008
0

Re: AJAX vs IE issue

Got it to work now. Thanks for all the help.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ciubhran is offline Offline
7 posts
since Aug 2008
Aug 15th, 2008
0

Re: AJAX vs IE issue

On the global/local declaration issue, one of the things going on is that Firefox's JS interpreter correctly handles variable scope (the variable only exists inside of the scope where it's declared) and IE's does not (all variables are effectively global).
Reputation Points: 18
Solved Threads: 4
Light Poster
chaosprime is offline Offline
46 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Troubleshoot script
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Ajax and server relation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC