是否可以使用jquery ajax的自动生成的回调和配置的回调名称?

时间:2021-07-26 20:36:06

I'm performing an AJAX JSONP call on a remote server. I want to use the standard jQuery AJAX call without specifying jsonpCallback, in order to use jQuery's auto generated callback mechanism. like this:

我正在远程服务器上执行AJAX JSONP调用。我想使用标准的jQuery AJAX调用而不指定jsonpCallback,以便使用jQuery的自动生成的回调机制。像这样:

$.ajax({
    url: thirdPartyUrl,
    dataType: "jsonp",
    cache: false
})

The problem is that the 3rd party server doesn't support callback name that contains underscores (only alphanumeric characters are allowed),
and whenever I request the data with the auto generated callback name it fails.

问题是第三方服务器不支持包含下划线的回调名称(仅允许使用字母数字字符),每当我使用自动生成的回调名称请求数据时,它都会失败。

Is there any option to configure the callback name without implementing the callback auto generation under the hood?

是否有任何选项可以配置回调名称而无需在引擎盖下实现回调自动生成?

EDIT: for example: when I call
http://thirdPartyUrl?ajaxParams&callback=jQuery1111029177630553022027_1431420222555 the server returns error message
but calling
http://thirdPartyUrl?ajaxParams&callback=jQuery1111029177630553022027
(or any other alphanumeric string as a callback) will success

编辑:例如:当我调用http:// thirdPartyUrl?ajaxParams&callback = jQuery1111029177630553022027_1431420222555服务器返回错误消息但调用http:// thirdPartyUrl?ajaxParams&callback = jQuery1111029177630553022027(或任何其他字母数字字符串作为回调)将成功

1 个解决方案

#1


_14314xxxxx for clean cache.try var a callback function with name and callback in url use that name

_14314xxxxx用于clean cache.try var一个回调函数,其名称和url中的回调使用该名称

#1


_14314xxxxx for clean cache.try var a callback function with name and callback in url use that name

_14314xxxxx用于clean cache.try var一个回调函数,其名称和url中的回调使用该名称