Answer the question
In order to leave comments, you need to log in
What is wrong with $.ajax() request to Telegram Bots API ("SyntaxError: Unexpected token :")?
Good evening!
Help me figure it out, please, I wrote a jQuery script that, on click, should $.ajax()
return JSON data from the Telegram Bots API through a request. But when I run it, it says SyntaxError: Unexpected token :
.
Here is the script:
var access_token = МОЙ_ТОКЕН;
$.ajax({
url: 'https://api.telegram.org/bot' + access_token + '/getMe',
dataType: 'jsonp',
success: function(response) {
console.log(response);
}
});
{"ok":true,"result":{"id":XXXXXXXX,"first_name":"BotName","username":"mybot_bot"}}
Answer the question
In order to leave comments, you need to log in
dataType: 'json',What does jsonp have to do with it ? Since the server gives json, specify it. Well, in general, there is $.getJSON().
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question