Re: [jQuery] AJAX loadIfModified() problems

2006-09-06 Thread John Resig
> I'm building a web page that periodically polls the server to display
> the status (OK, busy, loading, etc.)

jQuery doesn't actually check the returned contents from the server,
instead it sends the If-Modified-Since header to the server and checks
the Last-Modified response header coming back. Only if its the header
has been modified will jQuery actually report the data as also being
modified. This is an important distinction, and it relies upon your
script (if you're displaying things dynamically) you need to also
report a correct header. If you're only retrieving a static file,
smart web servers (like Apache) do this for you, so you don't need to
worry about it.

--John

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] AJAX loadIfModified() problems

2006-09-06 Thread Will Jessup
David,

are you loading the if-modified-since header from your target script?
 I seem to be having some challenges with the loadIfModified(url)
> function. Is the remote HTML "injected" if anything is returned by the
> URL, or if only what is returned that the previous time the URL was
> queried?
>
> I'm building a web page that periodically polls the server to display
> the status (OK, busy, loading, etc.)
>
> The following code does not appear to work (in Firefox 1.5):
>   setInterval(function() {
>   $('#status-container').loadIfModified('status.jsp');
>   }, 1000);
> ... however, using the "load" function instead of "loadIfModified" does
> seem to work:
>   setInterval(function() {
>   $('#status-container').load('status.jsp');
>   }, 1000);
>
> Suggestions?
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>
>
>
>   


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] AJAX loadIfModified() problems

2006-09-07 Thread Lewis, David
Hmmm ... My script is querying JSP pages that are accessed through a
proxied Apache server. There is no "Last-Modified" header being
automatically added, but as the response from the JSP is being generated
each time, that the header indicates a new "Date" value. Even when
bypassing Apache and making the requests directs to Tomcat, there is no
"Last-Modified" header being automatically added.

Would this suggest that I should modify my JSP to add this header and
update the value when the page response has been updated?

Suggestions? Thanks!

~ David

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: September 6, 2006 6:28 PM
To: jQuery Discussion.
Subject: Re: [jQuery] AJAX loadIfModified() problems

> I'm building a web page that periodically polls the server to display
> the status (OK, busy, loading, etc.)

jQuery doesn't actually check the returned contents from the server,
instead it sends the If-Modified-Since header to the server and checks
the Last-Modified response header coming back. Only if its the header
has been modified will jQuery actually report the data as also being
modified. This is an important distinction, and it relies upon your
script (if you're displaying things dynamically) you need to also
report a correct header. If you're only retrieving a static file,
smart web servers (like Apache) do this for you, so you don't need to
worry about it.

--John

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] AJAX loadIfModified() problems

2006-09-07 Thread Lewis, David
No, I'm not doing that ... It appears that I ought to, though! :-)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: September 6, 2006 6:29 PM
To: jQuery Discussion.
Subject: Re: [jQuery] AJAX loadIfModified() problems

David,

are you loading the if-modified-since header from your target script?
 I seem to be having some challenges with the loadIfModified(url)
> function. Is the remote HTML "injected" if anything is returned by the
> URL, or if only what is returned that the previous time the URL was
> queried?
>
> I'm building a web page that periodically polls the server to display
> the status (OK, busy, loading, etc.)
>
> The following code does not appear to work (in Firefox 1.5):
>   setInterval(function() {
>   $('#status-container').loadIfModified('status.jsp');
>   }, 1000);
> ... however, using the "load" function instead of "loadIfModified"
does
> seem to work:
>   setInterval(function() {
>   $('#status-container').load('status.jsp');
>   }, 1000);
>
> Suggestions?
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>
>
>
>   


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] AJAX loadIfModified() problems

2006-09-07 Thread John Resig
> Would this suggest that I should modify my JSP to add this header and
> update the value when the page response has been updated?

Yes, that is the "proper" (HTTP-spec) way of doing that - and what
jQuery currently supports. Although, it's certainly a possibility to
add in the content-checking capabilities, someday.

--John

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] AJAX loadIfModified() problems

2006-09-07 Thread Lewis, David
Thanks! I added a custom header to my JSP so that the "Last-Modified"
value is only updated when the page contents are updated. It is now
working very nicely with jQuery. :-)


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: September 7, 2006 3:29 PM
To: jQuery Discussion.
Subject: Re: [jQuery] AJAX loadIfModified() problems

> Would this suggest that I should modify my JSP to add this header and
> update the value when the page response has been updated?

Yes, that is the "proper" (HTTP-spec) way of doing that - and what
jQuery currently supports. Although, it's certainly a possibility to
add in the content-checking capabilities, someday.

--John

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/