]> source.dussan.org Git - jquery.git/commitdiff
Added an extra try block to handle FF 3 x-domain requests. (Bug #1557)
authorJohn Resig <jeresig@gmail.com>
Fri, 14 Dec 2007 02:04:00 +0000 (02:04 +0000)
committerJohn Resig <jeresig@gmail.com>
Fri, 14 Dec 2007 02:04:00 +0000 (02:04 +0000)
src/ajax.js

index 35995f6b640584cf3eae13a2a099486f8d82ba39..80cabd32d65001efd52d1505abeea1603ce97c99 100644 (file)
@@ -255,17 +255,20 @@ jQuery.extend({
                // Open the socket
                xml.open(s.type, s.url, s.async);
 
-               // Set the correct header, if data is being sent
-               if ( s.data )
-                       xml.setRequestHeader("Content-Type", s.contentType);
+               // Need an extra try/catch for cross domain requests in Firefox 3
+               try {
+                       // Set the correct header, if data is being sent
+                       if ( s.data )
+                               xml.setRequestHeader("Content-Type", s.contentType);
 
-               // Set the If-Modified-Since header, if ifModified mode.
-               if ( s.ifModified )
-                       xml.setRequestHeader("If-Modified-Since",
-                               jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
+                       // Set the If-Modified-Since header, if ifModified mode.
+                       if ( s.ifModified )
+                               xml.setRequestHeader("If-Modified-Since",
+                                       jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
 
-               // Set header so the called script knows that it's an XMLHttpRequest
-               xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+                       // Set header so the called script knows that it's an XMLHttpRequest
+                       xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+               } catch(e){}
 
                // Allow custom headers/mimetypes
                if ( s.beforeSend )