Sam is correct here - IE 7 fails to request local files using the traditional method. I also agree with your note about trying to use ActiveX, especially when it's disabled. Adapting his code a little bit I was able to come up with a solution and land it: http://github.com/jquery/jquery/commit/b2289f3ec174c5b22d130d8c36a5e07daa6d02df
The current logic is imperfect (in that, theoretically, someone could be trying to use jQuery on a local file, in IE 7, with ActiveX disabled and it would error out) but for now that's something that I can live with. (This fixed a number of outstanding bugs, as well.) I tested it in Firefox and IE 6 - and it still worked fine. I then loaded up IE 7 and disabled all ActiveX functionality and ran the Ajax tests - and they ran without a hitch (I double-checked 1.3.2 and they fail the ajax tests, under this condition). A bar still pops up that says "Your security settings do not allow websites to use ActiveX controls installed on your computer. This page may not display correct. Click here for options..." But I'm not sure what that's in relation to (commenting out *all* the ActiveX logic still causes the bar to still pop up). --John On Tue, Jan 5, 2010 at 10:16 AM, Sam Collett <sam.coll...@gmail.com> wrote: > Hi, > From what I recall from a few years back, XMLHttpRequest asynchronous > requests do not work with local files, which I think may be the reason why > ActiveX is used. Maybe check if it is being used on a local page (not > tested), e.g. > xhr: function() { > if (location.protocol !== "file:" && window.XMLHttpRequest && > window.ActiveXObject) > { > return new XMLHttpRequest(); > } > if (window.ActiveXObject) { > try { return new ActiveXObject("Microsoft.XMLHTTP"); } > catch(e) { } > } > if (window.XMLHttpRequest) { > return new XMLHttpRequest(); > } > return null; > } > --Sam > > 2010/1/5 Matt <m...@thekrusefamily.com> >> >> On Dec 31 2009, 1:52 pm, John Resig <jere...@gmail.com> wrote: >> > Landed and closed:http://dev.jquery.com/ticket/5735 >> >> John, good to see this change in jQuery. >> >> Another ajax area that needs attention is the xhr creation: >> >> // Create the request object; Microsoft failed to properly >> // implement the XMLHttpRequest in IE7, so we use the ActiveXObject >> when it is available >> // This function can be overriden by calling jQuery.ajaxSetup >> xhr: function(){ >> return window.ActiveXObject ? >> new ActiveXObject("Microsoft.XMLHTTP") : >> new XMLHttpRequest(); >> } >> >> >> 1) What problems exist in IE7 that make you prefer ActiveX? >> >> 2) If an IE user has ActiveX disabled (common for many corporate >> users), this will throw a nasty error like: >> "Automation server can't create object" >> to the user and cause scripts to stop running. This is not good, >> especially if the user has IE>=7 with native XMLHttpRequest that would >> work fine. >> >> Assuming you want to keep ActiveX as the preferred method in IE (I'd >> like to know why) then I suggest: >> >> xhr: function() { >> if (window.ActiveXObject) { >> try { return new ActiveXObject("Microsoft.XMLHTTP"); } >> catch(e) { } >> } >> if (window.XMLHttpRequest) { >> return new XMLHttpRequest(); >> } >> return null; >> } >> >> And then later in the ajax() method you need to check to make sure >> that xhr() doesn't return null. If it does, don't try to proceed. >> >> In fact, this should be a feature-test early on, so developers can >> decide whether ajax functionality will even be supported in the user's >> browser. Right now there isn't even a way to check for ajax support >> and degrade gracefully if it doesn't exist. >> >> jQuery.support.ajax = (xhr()!=null); >> >> Hope that helps some more, >> >> Matt Kruse >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> "jQuery Development" group. >> To post to this group, send email to jquery-...@googlegroups.com. >> To unsubscribe from this group, send email to >> jquery-dev+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/jquery-dev?hl=en. >> >> > > -- > > You received this message because you are subscribed to the Google Groups > "jQuery Development" group. > To post to this group, send email to jquery-...@googlegroups.com. > To unsubscribe from this group, send email to > jquery-dev+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/jquery-dev?hl=en. > -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.