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: Having trouble using XMLHttpRequest to refresh data



Yes, the function I am calling looks exactly like that, line for line save the comments.

Right at the top of the processReqChange() function, I output req.readyState (which I'd hope is 4) and it's always 0.  Again, I do have the proper plist boolean set to allow outside access.  I am losing my mind here.  

Thanks.



bp
On May 23, 2005, at 9:59 AM, Marc Tremblay wrote:

Does the code you're using to make the request look similar to this code?  Specifically, do you have both the req.open() and req.send() calls?

function refresh() {    

    req = new XMLHttpRequest();


    req.>

    req.open('GET', url, true);


    // this is the magic incantation to get subsequent XMLHttpRequest calls to work

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


    req.send(null);

}




On 22-May-05, at 1:28 PM, Blake Patterson wrote:

Thaddeus & Marc,

Trying both of these makes no difference.  When I output req.readyState at the top of processReqChange(), it's always 0.

What else could it be?  I am pulling my hair out here!  Thanks.




bp

On May 22, 2005, at 12:10 AM, Marc Tremblay wrote:

Another approach is to set the If-Modified-Since HTTP header to some time in the past.

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

Marc

On 21-May-05, at 11:26 AM, Thaddeus Cooper wrote:

This is a caching bug that I ran into as well. If the URL is the same every time then you get the undefined error. I "fixed" the problem by adding ?ts_cache=<currenttime> to the URL to make it different and the problem went away.

Hope that helps.

--Thaddeus O. Cooper

On May 21, 2005, at 8:45 AM, Blake Patterson wrote:


I have two chunks of HTML on my widget that I want to refresh with a timer, pulled from remote .js files that just do document.writes of HTML.  Poor man's RSS sort of - but my needs go beyond RSS so that's not an option for me.

Anyway, I wrote this demo that basically works:


I am trying to do the same thing in my widget, but it never works.  Let me explain.

In my loaded() function, called as onLoad in my BODY tag, I do this:


And that function I have defined as:

function loadXMLDoc(url) 
{
    if (window.XMLHttpRequest) {       
        req = new XMLHttpRequest();
        req.>
        req.open("GET", url, true);
        req.send(null);
    } 
}

...and this function calls:

function processReqChange() 
{
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
                    document.getElementById('news').innerHTML = "yo";
        } else {
            document.getElementById('news').innerHTML = "There was a problem retrieving the XML data:\n" + req.statusText;
        }
    }
}

And this is the block of code I am trying to replace (the element id = news)

    <span class="newsText">
        <br>
        <div id="news">start</div>
    </span>


...the problem is, req.readyState is always 0.  The state indicates UNDEFINED.  I do have:

    <key>AllowNetworkAccess</key>
    <true/>

In my plist.  What could be the issue?  I can hit the net fine from this machine.  I have been stumped for days here.  Any ideas?  The issue is not really whether it's updating the 'news' element id because, as I said, when I output req.readyState in the top of processReqChange, it's always 0...

req is defined as a global var at the start of the .js file for my widget.

Thanks for any help!




bp
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

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

This email sent to email@hidden


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

This email sent to email@hidden

 _______________________________________________
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: 
 >Having trouble using XMLHttpRequest to refresh data (From: Blake Patterson <email@hidden>)
 >Re: Having trouble using XMLHttpRequest to refresh data (From: Thaddeus Cooper <email@hidden>)
 >Re: Having trouble using XMLHttpRequest to refresh data (From: Marc Tremblay <email@hidden>)
 >Re: Having trouble using XMLHttpRequest to refresh data (From: Blake Patterson <email@hidden>)
 >Re: Having trouble using XMLHttpRequest to refresh data (From: Marc Tremblay <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.