T
T
toncho12018-10-07 17:56:33
JavaScript
toncho1, 2018-10-07 17:56:33

Why does LongPoll not work in VK API?

When trying to get message updates via Long Poll, an error occurs in the console that says a syntax error 5bba1d7f2d5bc081249968.png
The code itself:
//I call the method
vk.method("messages.getLongPollServer", {}, function(data){
let LongPoll = data.response //Save the key, server and ts
console.log(data) //Log them to the console
$.ajax({
url: "https://"+LongPoll.server+"?act=a_check&key="+LongPoll.key+"&ts ="+LongPoll.ts+"&wait=25", //Get data
method: "GET",
dataType: "JSONP",
success: function(resp){
console.log(resp); //Log received data to console
}
});
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2018-10-07
@toncho1

in browser JS you won't be able to use LongPoll due to Same Origin Policy
you need to use Node.JS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question