Skip to content

Commit

Permalink
Added an extra try block to handle FF 3 x-domain requests. (Bug #1557)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Dec 14, 2007
1 parent 14a3a5b commit 56a93fc
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/ajax.js
Expand Up @@ -255,17 +255,20 @@ jQuery.extend({
// Open the socket // Open the socket
xml.open(s.type, s.url, s.async); xml.open(s.type, s.url, s.async);


// Set the correct header, if data is being sent // Need an extra try/catch for cross domain requests in Firefox 3
if ( s.data ) try {
xml.setRequestHeader("Content-Type", s.contentType); // 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. // Set the If-Modified-Since header, if ifModified mode.
if ( s.ifModified ) if ( s.ifModified )
xml.setRequestHeader("If-Modified-Since", xml.setRequestHeader("If-Modified-Since",
jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" ); jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );


// Set header so the called script knows that it's an XMLHttpRequest // Set header so the called script knows that it's an XMLHttpRequest
xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
} catch(e){}


// Allow custom headers/mimetypes // Allow custom headers/mimetypes
if ( s.beforeSend ) if ( s.beforeSend )
Expand Down

0 comments on commit 56a93fc

Please sign in to comment.