user4005632
user4005632

Reputation:

Ajax request error with elasticsearch

I simple make get req with ajax to elasticsearc to get all indices, in browser it works here: enter image description here

its same in my ajax, I expected the json data in browser return to my success method but failed:

enter image description here

Upvotes: 1

Views: 175

Answers (2)

Joey.Huang
Joey.Huang

Reputation: 61

Response is not JSON,
you can change the response to a JSON in your server program.

Upvotes: 1

Val
Val

Reputation: 217474

It should work if you replace json by jsonp in your dataType parameter, like this:

$.ajax({
    url: "http://localhost:9200/dicoms/dicoms/_search",
    dataType: "jsonp",              <--- change this
    type: "GET",
    success: function(data) {
    ...
});

Upvotes: 1

Related Questions