# AJAX call - get request shows results of /\_search instead of the query

**URL:** <https://discuss.elastic.co/t/ajax-call-get-request-shows-results-of-search-instead-of-the-query/103685>\
**Category:** Elasticsearch\
**Created:** [October 12, 2017, 9:13am UTC](https://discuss.elastic.co/t/ajax-call-get-request-shows-results-of-search-instead-of-the-query/103685 "2017-10-12T09:13:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elvira](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@Elvira](https://discuss.elastic.co/u/Elvira)\
**Post date:** [October 12, 2017, 9:13am UTC](https://discuss.elastic.co/t/ajax-call-get-request-shows-results-of-search-instead-of-the-query/103685/1 "2017-10-12T09:13:44Z")

</div>

Hello,

I'm new to Kibana/Elasticsearch and I'm trying to get the data in Elasticsearch in Oracle apex.  
To get the data I'm using a AJAX GET request (JSONP, due to the http:// call from https://) to an endpoint, opening this endpoint in the browser works fine, I'm getting everything that is placed in /trefwoorden.

However when I run my code I'm getting a "Uncaught SyntaxError: UnExpected token : " error in Chrome and in the 'Sources' I'm getting a JSON with hits total 40710, meaning that every \_id is encountered.

I hope you can tell me whats wrong with the structure of my call or query

**I have the following code**  
var query ={  
"query": {  
"ids": {  
"type": "e\_book",  
"values": ["9789026333842"]  
}  
},  
"\_source": ["hoofdtitel"]  
}

```
$.ajax({
    url: "[endpoint]/trefwoorden/_search",
    method: "GET",
    crossDomain: true,
    dataType: 'jsonp',
    contentType: 'application/jsonp',
    success: function(data) {        
    console.log('succes',data);                
        alert("Success");
    },
    error: function(data) { },
   data: JSON.stringify(query)
});

```

This is the result I actually want to get (got this via Kibana):  
{  
"took": 0,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "trefwoorden\_1",  
"\_type": "e\_book",  
"\_id": "9789026333842",  
"\_score": 1,  
"\_source": {  
"hoofdtitel": "Als het zaterdag wordt"  
}  
}  
]  
}  
}

---

<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:** [November 9, 2017, 9:14am UTC](https://discuss.elastic.co/t/ajax-call-get-request-shows-results-of-search-instead-of-the-query/103685/2 "2017-11-09T09:14:03Z")

</div>

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