JSONP Support

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JSONP Support

Walendo
Hi again!

I'm facing a problem using JQuery do access my Elastic Search server
using getJSON method on Firefox 3.5 and Google Chrome 4.1.249.104.

The problem is that, from Firefox 3.5 on, the XMLHttpRequest must use
the JSONP (https://developer.mozilla.org/en/HTTP_access_control) in
order to get data from the server, so, even when the server answers ok
(Internet Explorer works fine), the firefox browser doesn't allow the
content to be loaded, requesting some additional headers or actions
(options method before post).

Do you know this limitation?

As a workaround for the GET methods, I can put an aditional header on
the response (Access-Control-Allow-Origin: *). Is it possible to
configure in Elastic Search?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: JSONP Support

kimchy
Administrator
Actually, I am not too familiar with this Access-Control-Allow-Origin, is this something the server returns in the header for a request? I can add a feature that this can be configured in elasticsearch to be returned.

Regarding JSONP, just add callback with your json function to your request, and elasticsearch will return the response in JSONP. I really should document this :).

cheers,
shay.banon

On Sun, Apr 11, 2010 at 9:26 PM, Walendo <[hidden email]> wrote:
Hi again!

I'm facing a problem using JQuery do access my Elastic Search server
using getJSON method on Firefox 3.5 and Google Chrome 4.1.249.104.

The problem is that, from Firefox 3.5 on, the XMLHttpRequest must use
the JSONP (https://developer.mozilla.org/en/HTTP_access_control) in
order to get data from the server, so, even when the server answers ok
(Internet Explorer works fine), the firefox browser doesn't allow the
content to be loaded, requesting some additional headers or actions
(options method before post).

Do you know this limitation?

As a workaround for the GET methods, I can put an aditional header on
the response (Access-Control-Allow-Origin: *). Is it possible to
configure in Elastic Search?

Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: JSONP Support

Walendo

Thanks! Actually, this JSONP stuff is new for me (I was developing
with flex/java/granite for 3 years).  Reading that document I noticed
that, passing the header Access-Control-Allow-Origin to tell who might
access the page was enough to solve my problem of GETting content from
the server. So I hardcoded it in the NettyHttpChannel code to test and
it worked.

Now I will "unhardcode", use the callback parameter and tell you if it
works, ok?

Thanks again!

On 11 abr, 20:58, Shay Banon <[hidden email]> wrote:

> Actually, I am not too familiar with this Access-Control-Allow-Origin, is
> this something the server returns in the header for a request? I can add a
> feature that this can be configured in elasticsearch to be returned.
>
> Regarding JSONP, just add callback with your json function to your request,
> and elasticsearch will return the response in JSONP. I really should
> document this :).
>
> cheers,
> shay.banon
>
> On Sun, Apr 11, 2010 at 9:26 PM, Walendo <[hidden email]>wrote:
>
> > Hi again!
>
> > I'm facing a problem using JQuery do access my Elastic Search server
> > using getJSON method on Firefox 3.5 and Google Chrome 4.1.249.104.
>
> > The problem is that, from Firefox 3.5 on, the XMLHttpRequest must use
> > the JSONP (https://developer.mozilla.org/en/HTTP_access_control) in
> > order to get data from the server, so, even when the server answers ok
> > (Internet Explorer works fine), the firefox browser doesn't allow the
> > content to be loaded, requesting some additional headers or actions
> > (options method before post).
>
> > Do you know this limitation?
>
> > As a workaround for the GET methods, I can put an aditional header on
> > the response (Access-Control-Allow-Origin: *). Is it possible to
> > configure in Elastic Search?
>
> > Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: JSONP Support

kimchy
Administrator
Can you open a feature request so you can provide the list of headers that return as part of each response? I will implement this (should be simple).

cheers,
shay.banon

On Mon, Apr 12, 2010 at 4:26 PM, Walendo <[hidden email]> wrote:

Thanks! Actually, this JSONP stuff is new for me (I was developing
with flex/java/granite for 3 years).  Reading that document I noticed
that, passing the header Access-Control-Allow-Origin to tell who might
access the page was enough to solve my problem of GETting content from
the server. So I hardcoded it in the NettyHttpChannel code to test and
it worked.

Now I will "unhardcode", use the callback parameter and tell you if it
works, ok?

Thanks again!

On 11 abr, 20:58, Shay Banon <[hidden email]> wrote:
> Actually, I am not too familiar with this Access-Control-Allow-Origin, is
> this something the server returns in the header for a request? I can add a
> feature that this can be configured in elasticsearch to be returned.
>
> Regarding JSONP, just add callback with your json function to your request,
> and elasticsearch will return the response in JSONP. I really should
> document this :).
>
> cheers,
> shay.banon
>
> On Sun, Apr 11, 2010 at 9:26 PM, Walendo <[hidden email]>wrote:
>
> > Hi again!
>
> > I'm facing a problem using JQuery do access my Elastic Search server
> > using getJSON method on Firefox 3.5 and Google Chrome 4.1.249.104.
>
> > The problem is that, from Firefox 3.5 on, the XMLHttpRequest must use
> > the JSONP (https://developer.mozilla.org/en/HTTP_access_control) in
> > order to get data from the server, so, even when the server answers ok
> > (Internet Explorer works fine), the firefox browser doesn't allow the
> > content to be loaded, requesting some additional headers or actions
> > (options method before post).
>
> > Do you know this limitation?
>
> > As a workaround for the GET methods, I can put an aditional header on
> > the response (Access-Control-Allow-Origin: *). Is it possible to
> > configure in Elastic Search?
>
> > Thanks.