Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XMLHTTPRequest Oddity



I'm running up against the same problem and the 'If-Modified-Since' header doesn't help. Any other thoughts on things to try? The snippet of code is:

function loadLinksysWirelessPage() {
    // pull IP and password
    var urlip;
    var urlpassword;
    if (window.widget) {
        urlip = widget.preferenceForKey(keyForRouterIP);
        urlpassword = widget.preferenceForKey(keyForRouterPassword);
    }
    var url = "" + urlpassword + "@" + urlip + urlend;
    debug(url);
    if (timerHtmlID == null) {
        htmlPageRequest = new XMLHttpRequest();
   
        htmlPageRequest.setRequestHeader("Cache-Control", "no-cache");
        htmlPageRequest.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
        htmlPageRequest.>
        htmlPageRequest.overrideMimeType('text/xml');

        htmlPageRequest.open("GET", url, true);
        htmlPageRequest.send(null);
   
        timerHtmlID = setInterval("htmlPageTimeout();", 2000);
    }

This is pulling information from a Linksys router through it's web interface. It needs a password to access it, but no username. The url looks something like "http://:email@hidden.1.1/WL_ActiveTable.asp". The first time through, it works beautifully. After that, I get a:

--> htmlPageRequest readyState: 4
--> htmlPageRequest status: undefined

and the content hasn't changed, though the data on the page has changed.

I've tried deleting the XMLHttpRequest object, setting it to null, deleting the responseText attribute (which comes back). I read that appending parameters in the form of "?id=" + (new Date).getTime(), with the server returning a 404 on that one. I wonder if flipping to a different web page and back would clear something enough to get new data?

Any thoughts are welcome.

Thanks,

Danny



  • Subject: Re: XMLHTTPRequest Oddity
  • From: Marc Tremblay <email@hidden>
  • Date: Sat, 14 May 2005 18:31:56 -0600
  • Delivered-to: email@hidden
  • Delivered-to: email@hidden

Hi Michael,

I had the same problem and managed to remedy it by setting the If-Modified-Since header to force XMLHttpRequest to send the request to the remote server rather than fetching it from the cache (at least that's what I believe is happening).

Basically you want to add something like the following before the call to send.

xmlReq.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');

See http://pansapien.com/?p=32 for full details.

Seems like this may be a bug with the XMLHttpRequest implementation in Safari 2.0, but I haven't checked into other implementations to know that this isn't just the way things work.

M.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden

References: 
 >XMLHttpRequest with password authentication? (From: Danny Rappleyea <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.