Hello,

Thanks for the suggestions/comments everyone. I agree that IE6 is dated, but
I would like to at least *try* to support it.

Plus, regardless of IE version, unexpected behavior really bothers me unless
I can figure it out. It is a bit of a game to me as well. I have primarily
been an application developer for the last 10 years. In my particular field,
web services were not practical in the past. That is quickly changing and I
want to update my skills as well. Hence, learning web stuff that I have come
across in the past, but just not spent a great deal of time with.

Adam, the suggestions below did not work. Thanks for the ideas though.

If anyone wants to take a crack at it, this is the script.html file.

<html>
<head>
    <title>The Simplest Ajax Script</title>
    <script type="text/javascript" src="script.js">
    </script>
</head>
</body>
    <div id="updateArea">&nbsp;</div>
</body>
</html>

And here is the complete script.js referenced by script.html (don't worry
about colors.xml, it is not really needed, you'll just get a 404 instead of
200 if nothing there)....

window.onload = makeRequest;
var xhr = false;

function makeRequest() {
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    }
    else {
        if (window.ActiveXObject) {
           try {
               xhr = new ActiveXObject("Microsoft.XMLHTTP");
           }
           catch (e) {}
        }
    }

    if (xhr) {
        xhr.onreadystatechange = showState;
        xhr.open("GET", "colors.xml", true);
        xhr.send(null);
    }
    else {
        document.getElementById("updateArea").innerHTML = "Sorry, but I
couldn't create an XMLHttpRequest";
    }
}

function showState() {
    var currMsg = document.getElementById("updateArea").innerHTML;
    document.getElementById("updateArea").innerHTML = currMsg + "<p>The
current state is " + xhr.readyState + " and the status is " + xhr.status +
"</p>";
}


If you run it on FF you will see states 2, 3, and 4. If you run it on IE6,
you'll see just state 4 and an error.

Regards,

~K

On Sun, May 24, 2009 at 3:33 PM, Adam Theriault <[email protected]>wrote:

> Just to be clear, heres' the two things I'd try:
>
>
>
> function showState() {
> var xhr = new XMLHttpRequest();
>     currMsg = document.getElementById(" updateArea").innerHTML;
>     document.getElementById("updateArea").innerHTML = currMsg + "<p>The
> current state is " + xhr.readyState + " and the status is " + xhr.status +
> "</p>";
> }
>
> if that doesn't work, try
>
> function showState() {
> var xhr = new XMLHttpRequest();
>     currMsg = document.getElementById(" updateArea").innerHTML;
>     document.getElementById("updateArea").innerHTML = currMsg;
> }
>
>
> if the first one works, great, if not, and the second one works, you'll
> have to decide what you want to do with IE6. You can create an exception
> using the try/catch statement.... info on that is here:
>
> http://www.w3schools.com/jS/js_try_catch.asp
>
> hope this helps.
>
>
>
> On Sun, May 24, 2009 at 3:31 PM, Adam Theriault <[email protected]>wrote:
>
>> I should point out that most JS frameworks support IE6, due to IE users
>> being sluggish on adoption rate for a myriad of reasons.
>>
>> That'll probably start to fall off pretty quickly when rumors of IE9 start
>> popping up, and major sites change their previous-current-next support
>> scheme to cover ie7-9 rather than the current 6-8.
>>
>>
>> As Paul said, seeing it in context would help, but shot in the dark:
>> s*ince that second line is one big value assignment, I'm guessing what it
>> might really have a problem with is:
>>
>> xhr.readyState
>>
>>
>> your starting a function, but not defining "xhr" in the function scope,
>> and it doesn't look like any variables are getting passed to the function.
>>
>> I'm guessing somehwere else in the code, you've got something like:
>>
>> *var xhr* = new *XMLHttpRequest*();
>>
>> move that inside this function and see if that helps.
>>
>>
>> Also, top of my head, but IE6 doesn't support a lot of XMLHttpRequest's
>> methods...so in addition to "xhr" being a potential problem here,
>> "readyState" might also be...I don't recall off the top of my head though.
>>
>>
>> Try removing that whole line, and if the function works okay, you know
>> it's one half or the other.
>>
>> -a
>>
>>
>>
>>
>>
>> On Sun, May 24, 2009 at 2:05 PM, Paul <[email protected]> wrote:
>>
>>> Kaffeen,
>>> Can you provide a URL to the page in question. Might be easier to help if
>>> we can take a look at it.
>>>
>>> Also, I sort of agree with the comment from Doug. Using a JS framework (I
>>> prefer jQuery) rather than hand coding. Though not impossible. Just better
>>> cross-browser handling via a framework. Not going to comment on the IE6
>>> thing.
>>>
>>> P-
>>>
>>> On May 24, 2009, at 11:15 AM, kaffeen wrote:
>>>
>>> First, I'm not sure if this group would be the correct one to use for
>>> this type of question. I've not really actively participated in this group,
>>> although I do read it frequently. My apologies if this is not the place for
>>> this, please let me know.
>>>
>>> Second, I have a bug in IE that I cannot seem to figure out. It is
>>> actually from a course on Lynda.com. I've not had much experience with Ajax,
>>> so I am taking one of those lessons there. This particular section of the
>>> lesson is related to the different states and status.
>>>
>>> The bug is related to the following snippet of code...
>>>
>>> function showState() {
>>>     currMsg = document.getElementById("updateArea").innerHTML;
>>>     document.getElementById("updateArea").innerHTML = currMsg + "<p>The
>>> current state is " + xhr.readyState + " and the status is " + xhr.status +
>>> "</p>";
>>> }
>>>
>>> Basically, this is just updating the browser with the status. In Firefox,
>>> it works fine and the output is as follows:
>>>
>>> *The current state is 1 and the status is 200*
>>>
>>> *The current state is 2 and the status is 200*
>>>
>>> *The current state is 3 and the status is 200*
>>>
>>> *The current state is 4 and the status is 200*
>>>
>>> In IE 6, I get this result (with an error):
>>>
>>> *The current state is 4 and the status is 200*
>>>
>>> If I examine the error, it is basically complaining about the
>>> document.getElementById("updateArea").innerHTML
>>>
>>> IE6 does not report any of the 1, 2, or 3 states.
>>>
>>> I don't have a Premium membership to Lynda, so it is quite possible there
>>> is a typo there, but I can't find it and it works fine with FF. In addition,
>>> I have googled this and found some things to try and interesting information
>>> about innerHTML and element/id bugs with IE, however, at this time, nothing
>>> has really resolved this particular error for me.
>>>
>>> If anyone understands this bug/error, please let me know how to correct
>>> in IE.
>>>
>>> Kind Regards,
>>>
>>> Kaffeen
>>>
>>>
>>> -- If you understand, things are just as they are. If you do not
>>> understand, things are just as they are.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
> >
>


-- 
If you understand, things are just as they are. If you do not understand,
things are just as they are.

--~--~---------~--~----~------------~-------~--~----~
Our Web site: http://www.RefreshAustin.org/

You received this message because you are subscribed to the Google Groups 
"Refresh Austin" group.

[ Posting ]
To post to this group, send email to [email protected]
Job-related postings should follow http://tr.im/refreshaustinjobspolicy
We do not accept job posts from recruiters.

[ Unsubscribe ]
To unsubscribe from this group, send email to 
[email protected]

[ More Info ]
For more options, visit this group at 
http://groups.google.com/group/Refresh-Austin
-~----------~----~----~----~------~----~------~--~---

Reply via email to