I'm confused by something I found in the definition of $.ajax in the jQuery source, and would greatly appreciate it if someone could shed some light on the matter. The part of the code in question is this (I've made a couple of minor formatting changes for clarity):
// If we're requesting a remote document // and trying to load JSON or Script with GET if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && ( s.dataType == "script" || s.dataType =="json" ) && s.type.toLowerCase() == "get" ) { var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); /* * definition of script omitted */ head.appendChild(script); // We handle everything using the script element injection return undefined; } I understand what the test at the top is testing for, but I don't understand the policy implemented by the code that runs when the test evaluates to true. Couldn't a script be requesting simple JSON data ( e.g. the JSON string '[ "foo" ]') via GET? I think the code shown above would cause such a script to fail. This code suggests to me that jQuery expects such data to come only from relative URLs, but I don't understand what justifies this expectation. TIA!