1

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

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

6 Comments

I see but actually it was because of "Access-Control-Allow-Origin". I install a plugin that's fine now.
You means your ajax's host is different from the data provider, in that case, you need "Access-Control-Allow-Origin" to cross-host. Very well.
my development platform is .net mvc. (if it is your porint) yes its. But I did not understand whats problem with that. I simply make a request from ajax whats wrong with .net _?
I mean the ajax page url is http://www.test.local/../..., but the data provider is http://localhost:9200/_cat/..., in this case, your ajax request need to cross-host, just what you do with "Access-Control-Allow-Origin" if your two page are both the same host like:http://www.abc.local/../... ajax request did not need to cross-host
But my both ajax host(localhost:55421/Builder/Index) and data provider(localhost:9200) in same host(localhost). Just ports are diffirent..why it ask for access cross host ? because of ports or ?
|
1

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) {
    ...
});

1 Comment

it was because of "Access-Control-Allow-Origin". I install a plugin now it works but wonder what's that mean

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.