# JSONP Support

**URL:** <https://discuss.elastic.co/t/jsonp-support/2903>\
**Category:** Elasticsearch\
**Created:** [April 11, 2010, 6:26pm UTC](https://discuss.elastic.co/t/jsonp-support/2903 "2010-04-11T18:26:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Walendo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/walendo/32/3348_2.png) [@Walendo](https://discuss.elastic.co/u/Walendo)\
**Post date:** [April 11, 2010, 6:26pm UTC](https://discuss.elastic.co/t/jsonp-support/2903/1 "2010-04-11T18:26:16Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 11, 2010, 11:58pm UTC](https://discuss.elastic.co/t/jsonp-support/2903/2 "2010-04-11T23:58:03Z")

</div>

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 [jorge.walendowsky@gmail.com](mailto:jorge.walendowsky@gmail.com)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](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.

---

<div class="post-metadata">

**Author:** ![Walendo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/walendo/32/3348_2.png) [@Walendo](https://discuss.elastic.co/u/Walendo)\
**Post date:** [April 12, 2010, 1:26pm UTC](https://discuss.elastic.co/t/jsonp-support/2903/3 "2010-04-12T13:26:40Z")

</div>

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 [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) 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 [jorge.walendow...@gmail.com](mailto:jorge.walendow...@gmail.com)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](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.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 12, 2010, 2:22pm UTC](https://discuss.elastic.co/t/jsonp-support/2903/4 "2010-04-12T14:22:46Z")

</div>

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 [jorge.walendowsky@gmail.com](mailto:jorge.walendowsky@gmail.com)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 [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) 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 \<[jorge.walendow...@gmail.com](mailto:jorge.walendow...@gmail.com)  
> > 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](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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:24am UTC](https://discuss.elastic.co/t/jsonp-support/2903/5 "2017-07-06T04:24:42Z")

</div>


