Test case for jQuery Ticket 8054
jsonp stuff
by jitter
HTML
<p>Should it even switch to jsonp at all when I explicitly set dataType to json?</p>
<pre id="log"></pre>
JavaScript
function log( str ) {
$("#log").append(str+"\n");
}
$.ajaxSetup({
type: "GET",
dataType: "json",
cache: true,
beforeSend: function( xhr, settings ) {
log( settings.url );
return false;
},
success: function( data ) {
log( "success: ", data.test );
},
error: function( xhr, status, err ) {
log( status, err );
}
});
//ok
$.ajax({ url: "/echo/json/" });
//ok
$.ajax({ url: "/echo/json/?foo=" });
//wrong? the dataType explicitly says json not jsonp so why does ?? get picked up?
$.ajax({ url: "/echo/json/??" });
//undocumented (!) shouldn't this only happen
//if the "jsonp" option is set to "foo"
//happens in 1.4.4 and 1.5rc
$.ajax({ url: "/echo/json/?foo=?" });
//wrong in 1.5rc the ? is escaped and shouldn't be picked up
$.ajax({ url: "/echo/json/?foo=%3F" });
//is this ok in 1.5rc? shouldn't the context-insensitve ?? only match if
//at end of the path not when found in query part
$.ajax({ url: "/echo/json/?foo=??" });
//wrong in 1.5rc ?? is escaped and shouldn't be picked up
$.ajax({ url: "/echo/json/?foo=%3F%3F" });