服务器不会接受请求URL中的任何参数,因此我需要删除URL中的所有额外参数,当然我无法控制服务器.
jQuery的:
$.ajax({
type: 'GET',
url: 'http://cross-domain.com/the_jsonp_file,
jsonpCallback: 'jsonCallback',
contentType: 'application/json',
cache: 'true',
dataType: 'jsonp',
success: function(json) {
console.log(json);
},
});
Run Code Online (Sandbox Code Playgroud)
JSONP文件:
jsonCallback({"test": "hello"});
Run Code Online (Sandbox Code Playgroud)
当我发送Ajax请求时,URL如下所示:
http://cross-domain.com/the_jsonp_file?callback=jsonCallback
Run Code Online (Sandbox Code Playgroud)
但我需要这个(没有参数):
http://cross-domain.com/the_jsonp_file
Run Code Online (Sandbox Code Playgroud)
编辑:
这是我的整个情况:
function MyClass(imgs) {
// imgs is array of URLs
this.imgs = imgs;
this.submit = function() {
// button click event triggers this method
this._show();
};
this._show = function() {
var _this = this;
for (var i = 0; i < _this.imgs.length; i++) {
(function($, j) {
$.ajax({
type: 'GET',
url: …
Run Code Online (Sandbox Code Playgroud)