I
I
ixon2015-06-05 22:19:48
PHP
ixon, 2015-06-05 22:19:48

How to make a cross-domain request for json using jQuery?

I have this code, but it doesn't work:

var url = "https://2ch.hk/abu/res/1.json";
$.ajax({
type: 'GET',
url: url,
dataType: 'json',
success: function (data) {console.log(data);}
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valentin Dubrovsky, 2015-06-05
@matroskin13

The server should return the following header: Access-Control-Allow-Origin: *
If this is a public api, then most likely jsop is implemented there

P
Pavel Kononenko, 2015-06-05
@premas

With dvacha in any way the data cannot be pulled off by an ajax. Make a request through your server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question