No, I don't think there is. When you use JSONP or other script-tag
techniques, jQuery creates the script tag DOM element, but I don't think it
can get any response if the script fails to load. Whatever happens, happens.

It's technically possible to simulate a timeout by wrapping the JSONP
callback function, wait for the timeout period, and then check to see if the
callback function set some known value.  If it hasn't set this value after
the defined timeout interval, destroy the callback function and script tag,
and trigger a timeout.  I built a custom JSONP function that does this since
jQuery didn't back when I needed it.  I've been meaning to look at core and
contribute a patch to simulate timeouts for JSONP calls, but the code is
pretty wacky so I haven't had time to parse it and understand how a patch
like this might work.  Not sure if the state of affairs has changed since
1.1.2...

Scott

On Tue, Apr 15, 2008 at 3:52 PM, patrick davey <[EMAIL PROTECTED]>
wrote:

>
> Hi,
>
> I am trying to retrieve JSON Data  from a remote server and manipulate
> teh returned data.  That all works fine - the callback is executed and
> it all works as expected.  The issue I am running into is that I want
> to use timeouts and error messages also - and they are not working.
>
> I tried the following code (just demo code - not the one I am using)
>
>       $.ajax({
>               type:"GET",
>               url: "http://www.thisSite.com/badurl.asp";,
>               data:"jsoncallback=?",
>               dataType: "json",
>           timeout: 1000,
>           error: function(){
>               alert('Error loading document');
>           },
>           success: function(data){
>              alert(data);
>           }
>       });
>
> If I run the above function I would expect the error function to be
> called as it would get a 404 error for the bad URL... but that *does
> not happen*.  No function is called.  If, however, you change the URL
> to be a local address (but still incorrect) then the error function
> *is* called.
>
> I'm sure I'm missing something fundamental!! But is there a way to
> call error functions for remote urls?  And if so how!
>
> Thanks,
> Patrick
>



-- 
--
Scott Trudeau
scott.trudeau AT gmail DOT com
http://sstrudeau.com/
AIM: sodthestreets

Reply via email to