X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=ccf4f14a95f89048b842a048b5b5984a8433e95b;hb=456f0fe5985eaad42eba456b9ff710771669607c;hp=9d4e8b512862d21d10cbff4d3a26fd3a70878401;hpb=6b8ffe79f4e616d6179f6b16099e7c25e7ae5cb1;p=jquery.git
diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js
index 9d4e8b5..ccf4f14 100644
--- a/src/ajax/ajax.js
+++ b/src/ajax/ajax.js
@@ -11,10 +11,11 @@ jQuery.fn.extend({
* @name loadIfModified
* @type jQuery
* @param String url The URL of the HTML file to load.
- * @param Hash params (optional) A set of key/value pairs that will be sent to the server.
+ * @param Map params (optional) Key/value pairs that will be sent to the server.
* @param Function callback (optional) A function to be executed whenever the data is loaded (parameters: responseText, status and response itself).
- * @cat AJAX
+ * @cat Ajax
*/
+ // DEPRECATED
loadIfModified: function( url, params, callback ) {
this.load( url, params, callback, 1 );
},
@@ -22,6 +23,9 @@ jQuery.fn.extend({
/**
* Load HTML from a remote file and inject it into the DOM.
*
+ * Note: Avoid to use this to load scripts, instead use $.getScript.
+ * IE strips script tags when there aren't any other characters in front of it.
+ *
* @example $("#feeds").load("feeds.html");
* @before
* @result 45 feeds found.
@@ -38,21 +42,27 @@ jQuery.fn.extend({
* @param String url The URL of the HTML file to load.
* @param Object params (optional) A set of key/value pairs that will be sent as data to the server.
* @param Function callback (optional) A function to be executed whenever the data is loaded (parameters: responseText, status and response itself).
- * @cat AJAX
+ * @cat Ajax
*/
load: function( url, params, callback, ifModified ) {
- if ( url.constructor == Function )
+ if ( jQuery.isFunction( url ) )
return this.bind("load", url);
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
callback = callback || function(){};
// Default to a GET request
var type = "GET";
// If the second parameter was provided
- if ( params ) {
+ if ( params )
// If it's a function
- if ( params.constructor == Function ) {
+ if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
callback = params;
params = null;
@@ -62,7 +72,6 @@ jQuery.fn.extend({
params = jQuery.param( params );
type = "POST";
}
- }
var self = this;
@@ -73,15 +82,26 @@ jQuery.fn.extend({
data: params,
ifModified: ifModified,
complete: function(res, status){
- if ( status == "success" || !ifModified && status == "notmodified" ) {
- // Inject the HTML into all the matched elements
- self.html(res.responseText)
- // Execute all the scripts inside of the newly-injected HTML
- .evalScripts()
- // Execute callback
- .each( callback, [res.responseText, status, res] );
- } else
- callback.apply( self, [res.responseText, status, res] );
+ // If successful, inject the HTML into all the matched elements
+ if ( status == "success" || !ifModified && status == "notmodified" )
+ // See if a selector was specified
+ self.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(/