# Ajax call to open the Kibana page

**URL:** <https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428>\
**Category:** Kibana\
**Created:** [March 14, 2017, 12:20am UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428 "2017-03-14T00:20:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tushar\_Suvarna](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tushar\_Suvarna](https://discuss.elastic.co/u/Tushar_Suvarna)\
**Post date:** [March 14, 2017, 12:20am UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/1 "2017-03-14T00:20:35Z")

</div>

Hi,

I am trying to make sample ajax call to the kibana server running on port 5601 on my local computer.  
But I am getting an "Failed to load resource: Preflight response is not successful". I have not enabled any xpack or security packages.

I am trying to do achieve Authentication handshake between the Kibana and localserver with an AJAX call before rendering the data from the kibana.

for now a sample ajax call is giving me preflight error when I am calling from one local server with port 8080 to kibana server port 5601.

Can Anyone help me with this.

Sample Call  
var ajaxSuccess = function (response) {  
console.log("Success");  
};

```
var ajaxError = function() {
	console.log("Error");
	
	
};

		$.ajax({
	  type: "POST",

```

// xhrFields: {  
// withCredentials: true  
// },  
// data:loginData,  
// contentType: "application/x-www-form-urlencoded",  
// crossDomain: true,  
// beforeSend : function(xhr) {  
// xhr.setRequestHeader('Authorization' ,btoa("user" + ":" + "admin"));  
// },  
// headers: {  
// 'Access-Control-Allow-Credentials':true,  
// 'Access-Control-Allow-Origin': '\*',  
// 'Access-Control-Allow-Methods':'GET, POST, OPTIONS, PUT, PATCH, DELETE',  
// 'Access-Control-Allow-Headers':'X-Requested-With,content-type,Authorization',  
// 'Access-Control-Max-Age': '1728000'  
// },  
url :"[http://localhost:5601](http://localhost:5601)",  
dataType: "json",  
// jsonpCallback: "ajaxSuccess",  
success: ajaxSuccess,  
error: ajaxError  
});

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [March 14, 2017, 12:12pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/2 "2017-03-14T12:12:57Z")

</div>

Hi @Tushar_Suvarna,

Could you open your browser's developer tools console, networking tab? There should be an `OPTIONS` request in there. Could you copy/paste the details, specifically the request and response headers, of that request here?

Thanks,

Shaunak

---

<div class="post-metadata">

**Author:** ![Tushar\_Suvarna](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tushar\_Suvarna](https://discuss.elastic.co/u/Tushar_Suvarna)\
**Post date:** [March 15, 2017, 7:05pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/3 "2017-03-15T19:05:55Z")

</div>

Hi Sorry for my Late reply .

below is the images for the request and response

 ![](https://us1.discourse-cdn.com/elastic/original/3X/4/d/4d9c50b94442a59d1e2b5caa5313f820e44eb3a9.png) ![](https://us1.discourse-cdn.com/elastic/original/3X/2/2/227d1c1b2bf59993d02d61200f3125a5a184160e.png) ![](https://us1.discourse-cdn.com/elastic/original/3X/5/5/55c1d37de0147f89e26bbc2690c2e1adac10d10d.png)

---

<div class="post-metadata">

**Author:** ![Tushar\_Suvarna](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tushar\_Suvarna](https://discuss.elastic.co/u/Tushar_Suvarna)\
**Post date:** [March 15, 2017, 7:06pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/4 "2017-03-15T19:06:31Z")

</div>

@shaunak

---

<div class="post-metadata">

**Author:** ![Tushar\_Suvarna](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tushar\_Suvarna](https://discuss.elastic.co/u/Tushar_Suvarna)\
**Post date:** [March 15, 2017, 7:36pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/5 "2017-03-15T19:36:55Z")

</div>

@shaunak

Chrome Developer tools previous was for Safari:

 ![](https://us1.discourse-cdn.com/elastic/original/3X/c/7/c79cf65f8402a144787631e8860d50dc83fa781a.png) ![](https://us1.discourse-cdn.com/elastic/original/3X/8/e/8eaad2cea6cecf1f4e42668d16205f09325d1de9.png) ![](https://us1.discourse-cdn.com/elastic/original/3X/2/a/2a3580dc1695d5a64918f325b0896d79bcfe2994.png)

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [March 17, 2017, 2:58pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/6 "2017-03-17T14:58:54Z")

</div>

Hmm... looks like you're getting a 404 from the `OPTIONS` request. I see that the request is being made to `http://localhost:5601` with the `Access-Control-Request-Method` header set to `POST`. Since `http://localhost:5601` does not support `POST` requests, you are getting a 404 back.

> I am trying to do achieve Authentication handshake between the Kibana and localserver with an AJAX call before rendering the data from the kibana.

Could you elaborate on this a bit more? You mentioned that you are not using xpack or any security packages. Does your Kibana instance require authentication some other way?

---

<div class="post-metadata">

**Author:** ![Tushar\_Suvarna](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tushar\_Suvarna](https://discuss.elastic.co/u/Tushar_Suvarna)\
**Post date:** [March 17, 2017, 4:06pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/7 "2017-03-17T16:06:42Z")

</div>

@shaunak

As of now I am not using any authentication for kibana,just wanted to hit the Kibana and get an success reponse. I am planning to use the authentication once kibana is able to handle the ajax calls.

Also using curl POST command I am able to achieve the success call.

> **Since [http://localhost:5601](http://localhost:5601) does not support POST requests, you are getting a 404 back.**

I have seen some discussions \> [Authenticating to iframe-embedded Kibana dashboard - #7 by weltenwort](https://discuss.elastic.co/t/authenticating-to-iframe-embedded-kibana-dashboard/71129/7) on the POST commands. Can you please elaborate why Kibana does not work on POST calls and is there some other calls which can be passed to Kibana like 'GET/PUT'

---

<div class="post-metadata">

**Author:** ![Tushar\_Suvarna](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tushar\_Suvarna](https://discuss.elastic.co/u/Tushar_Suvarna)\
**Post date:** [March 21, 2017, 6:30pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/8 "2017-03-21T18:30:35Z")

</div>

@shaunak

Thanks for all the help I figured out what you meant and found a better way to meet my requirement and its working.

Regards  
Tushar

---

<div class="post-metadata">

**Author:** ![M.S.S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m.s.s/32/134307_2.png) [@M.S.S](https://discuss.elastic.co/u/M.S.S)\
**Post date:** [April 18, 2017, 12:23pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/9 "2017-04-18T12:23:51Z")

</div>

Hi there,  
What was the "better way"? Can you tell me please?  
I'm trying to use kibana visual, inside my web app but i need to authenticate with ajax call. Same preflight error happens.

---

<div class="post-metadata">

**Author:** ![Tushar\_Suvarna](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Tushar\_Suvarna](https://discuss.elastic.co/u/Tushar_Suvarna)\
**Post date:** [April 18, 2017, 3:29pm UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/10 "2017-04-18T15:29:34Z")

</div>

Hi,

There is no way to do so through Ajax call, because when an Ajax call is made for Cross Domain the method type "OPTIONS" is passed to the server and Kibana does not have a way to handle OPTIONS call in there product built code. They gave an option of using proxy server where you can authenticate and pass the request forward, but that still did not work for me as iframe cannot be shared in CROSS Domain.

Hope that suffice what you wanted.

Regards  
Tushar

---

<div class="post-metadata">

**Author:** ![M.S.S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m.s.s/32/134307_2.png) [@M.S.S](https://discuss.elastic.co/u/M.S.S)\
**Post date:** [April 19, 2017, 6:02am UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/11 "2017-04-19T06:02:23Z")

</div>

Thanks, answer is very helpful for me, i will look for a non cloud way.  
Regards.

---

<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:** [May 17, 2017, 6:10am UTC](https://discuss.elastic.co/t/ajax-call-to-open-the-kibana-page/78428/12 "2017-05-17T06:10:16Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
