[thelist] aol ajax problems

Brian Cummiskey Brian at hondaswap.com
Wed Apr 23 15:58:21 CDT 2008


Brian Cummiskey wrote:
> In doing a simple alert, aol never gets to readystate of 200.  it dies 
> with a 400 error.
>   

Replying to myself here....   typo'ed that up.  :X

What i meant to say was:

In doing a simple alert, AOL never gets to xmlhttp.status of 200 in 
readystate2, 3, or 4.  all 3 readystates return 400 (bad/malformed request)


With this, it seems that my server isn't liking the way AOL is packaging 
the http post.


my code is huge and 90% irrelevant to the issue at hand, but here's the 
main blocks.



function GetXmlHttpObject() {
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   alert("XMLHttpRequest not supported");
   return null;
 }

var xmlHttp = GetXmlHttpObject();



function addtobag() {

    //basic validation
    // build out params  etc etc

    //alert(params);

    //date to pass a unique param each time to prevent caching
    timestamp = new Date();
    tim1 = (timestamp.getTime());
    sec1 = timestamp.getSeconds();
    ms1 = timestamp.getMilliseconds();
    thetime = tim1+sec1+ms1;

    params += "&rand="+thetime
    params += "&rcount="+ rcount;
 
    var url = "/addtocart.asp";

    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        return;
    }
   

    xmlHttp.onreadystatechange = alertContents;
    xmlHttp.open('POST',url,true);   
    xmlHttp.setRequestHeader("Content-type", 
"application/x-www-form-urlencoded; charset=UTF-8");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
}

function alertContents() {

    if (xmlHttp.readyState == 4) {    
        //alert("status = " + xmlHttp.status);
        if (xmlHttp.status == 200) {           
            result = xmlHttp.responseText;
            document.getElementById("rcartitems").innerHTML = result;   
        }
        else {
            //ajax not working... send it the old fashioned way
            document.getElementById("addtocart").submit();
        }
    }
 }   






as you can see, i've circled the event to use a regular form submit if 
status never meets 200 and bombs.

I've tried ISO8851 charset instead of utf-8, but still no go.


Thanks!



More information about the thelist mailing list