id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,blocking,blockedby
11264,evalScript() uses defaults set by ajaxSetup(),Matthijs Kooijman <matthijs@…>,Matthijs Kooijman <matthijs@stdin.nl>,"When evalScript is loading a script (for example since the HTML loaded by .load() or set by .html() contains a script tag), it uses the .ajax() function to get the contents of that script. This ajax call is affected by the defaults set by the user through ajaxSetup().

Since this is an internal .ajax() call, it would make sense to have it bypass the defaults configured by the user, since those might cause unexpected results (users set those defaults to simplify their own ajax calls).

The particular problem I was running into was that ajaxSetup was used to make ajax() default to doing POST requests, causing jquery to do a POST request to a static JS file (resulting in a 405 Invalid request form nginx).

Here's a minimal example showing the problem. If you put this in a .html file, open it up in a browser, you'll see (in Firebug, for example) that POST request happens to foo.js.

{{{
<script src=""http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js""></script>
<div id=""content""></div>
<script>
    $.ajaxSetup({type: 'POST'});

    $(""#content"").html(""<div><script src=\""foo.js\""></sc"" +
        ""ript><p>Hello, world!</p></div>"");
</script>
}}}

A minimal way to fix this would be to make evalScript explicitely pass type:'POST' to ajax(), but I'm afraid there might be other conflicting settings as well (though I can't give any specific examples...).

On a related note, evalScript should probably pass global: false as well, to prevent globally registered callbacks from running on this internal request (though I guess people might want to register callbacks to run on _every_ request, not just the request they originate themselves...).",bug,closed,low,1.7.2,ajax,1.7.1,fixed,,,,
