Prevent jquery add your own callback

I try to call the Vimeo API using $.ajax(), but Jquery adds a callback to my URL, even when I specify my own named function. I need full control over the GET URL string.

My code is:

function fback(data) {
    alert('data = ' + data);
}

$.ajax({
    url: 'http://vimeo.com/api/v2/group/processing/videos.json?format=jsonp&callback=fback',
    dataType: "jsonp",
    type: "GET",
    cache: true,
    success: fback,
});

GET request:

http://vimeo.com/api/v2/group/processing/videos.json?format=jsonp&callback=fback&callback=jsonp1291384300228

How can I avoid this auto add callback?

+3
source share
1 answer

You just need to specify the jsonpCallbackoption as the name of the function after which you want:

$.ajax({
    url: 'http://vimeo.com/api/v2/group/processing/videos.json?format=jsonp&callback=?',
    jsonpCallback: "fback",
    dataType: "jsonp",
    type: "GET",
    cache: true
});

, , ( , ), `` fback ', :

http://vimeo.com/api/v2/group/processing/videos.json?format=jsonp&callback=fback

.

+3

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


All Articles