A strange get request on bilibili's website

when checking bilibili, I found a strange GET request:

https://api.bilibili.com/x/web-show/res/loc?callback=jQuery17207120742371497628_1532268552145&pf=0&id=142&jsonp=jsonp&_=1532268552332

what"s a lot of stuff behind the question mark?

jQuery17207120742371497628_1532268552145 what does this mean

related codes

https://api.bilibili.com/x/web-show/res/loc?callback=jQuery17207120742371497628_1532268552145&pf=0&id=142&jsonp=jsonp&_=1532268552332

which great god will answer the question

Mar.29,2021

since you know the GET request, don't you know that the question mark is followed by parameter string ?

the jQuery17 of the parameters "callback" is obviously the name of a (generated) local callback function, which can be confirmed with the following jsonp=jsonp .

if you don't understand, you can give Baidu a definition of JSONP .

as for other parameters, _ looks like a timestamp, id has nothing to say, pf doesn't know, maybe it's a status parameter, maybe it's a page parameter.


Cross-domain request, jsonp


this is a JSONP request, which uses the cross-domain feature of script tags to solve cross-domain front and back end cross-domain problems.
A function in the front end is

function callback(data) {
    // data
}

the front end sends a request with the name of callback, and the back end returns a js file whose content is: (data, that is, the returned data)

callback(data)

so that the front end only needs to create a script tag using the requested link and mount it to the page, then the function will run automatically and the data returned by the back end will be obtained from the parameters

.

as for the large string after jQuery, it is actually a unique identifier to avoid the return result string of different requests when there are multiple callback.

Menu