How to get JSON correctly after calling AJAX?

I spent a lot of time on this task and spent many hours of research, but I still have no solution.

I get error 401

But if I add this to the end of the url :? jsonpcallback =?

I get this in the console: Uncaught SyntaxError: Unexpected token:

Can someone direct me to this, please, and tell me what I'm doing wrong. Thank you in advance!

Here is my code:

  $.ajax({
        type: "GET",
        url: "XXX/jsonpcallback=?",
        dataType: 'jsonp',
        crossDomain:true,
        success: function (data){
            console.log(data);
        },
        error: function (err) {
            console.log(err)
        }
    });
+4
source share
1 answer

Try it.

$.getJSON('XXX/jsonpcallback=?xxx', function(data) {
     console.log(data);
});
0
source

Source: https://habr.com/ru/post/1673175/


All Articles