Ooops... the part "|| location.protocol == 'resource:'" is there cause this
was html running from a XULRUNNER application, you can leave it or take it
away, it wont make any difference....


On Thu, Dec 18, 2008 at 11:25 AM, Iván Núñez Paz <[email protected]> wrote:

> I needed this "feature" not long ago for a project of mine and I was
> suggested here in the group to do smth like this:
>
> [CODE]
> //Fix Ajax to allow for loading from file:// urls
> if (location.protocol == 'file:' || location.protocol == 'resource:') {
>     Request.implement({
>         isSuccess: function() {
>             return (!this.status || (this.status >= 200) && (this.status <
> 300));
>         }
>     });
> }
> [/CODE]
>
> Place it in the DOMREADY, before doing any request at all...
>
> Needless to say, it works like a charm.... and you still use REQUEST as
> usual, without worrying if its local or remote... In my particular project,
> it would be a CDROM based application, and all "htmls" were requested
> directly from the CD....
>
> Cheers!
>
>
>
> On Tue, Dec 16, 2008 at 7:47 PM, hellspawn <[email protected]> wrote:
>
>>
>> very nice
>> is a brilliant idea
>>
>> thanks a lot :), both of you guys
>>
>>
>> On Dec 16, 6:38 pm, Sanford Whiteman <[email protected]>
>> wrote:
>> > > I want a fallback to the request in case the script is run not by url
>> > > but with open file from the browser, so i need to know if the request
>> > > is working or not
>> >
>> > Without questioning the need to handle errors from Request in general,
>> > I  think  you  should  trap the fact that you're running from the file
>> > system as early as possible, set a flag, and just short-circuit before
>> > you  even  try the AJAX calls. Check `location.protocol` (just shorter
>> > than  what  Steve  said).
>> >
>> > Another  reason  to  do  it  this  way  is  you  ensure that you won't
>> > confusingly  have a mixture of working and non-working AJAX... say you
>> > have  some  absolute  URLs  or  some  mashed-up  requests to 3rd-party
>> > servers, which would otherwise work unless you force everything local.
>> >
>> > --Sandy
>>
>
>
>
> --
> ◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦
> Iván Núñez Paz | Comunica Online | Tel. 902 945 321
> http://comunicaonline.net/
>



-- 
◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦
Iván Núñez Paz | Comunica Online | Tel. 902 945 321
http://comunicaonline.net/

Reply via email to