The server won't accept any parameters in a request URL, so I need to remove all the extra parameters in the URL and of course I can't control the server.
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);
????},
});
The JSONP file:
jsonCallback({"test": "hello"});
When I send that Ajax request, the URL looks like this:
http://cross-domain.com/the_jsonp_file?callback=jsonCallback
But I need this (without parameters):
http://cross-domain.com/the_jsonp_file
EDIT:
Here is my whole situation:
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: _this.imgs[j],
jsonp : false,
jsonpCallback: 'jsonCallback',
cache: 'true',
dataType:'jsonp',
success: function(json) {
console.log(_this.imgs[j]);
????},
});
})(jQuery, i);
};
};
};
And I got this error message:
Uncaught TypeError: Property 'jsonCallback' of object [object Window] is not a function
Weird thing is few requests are successfully calling jsonCallback.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…