Skip to main content

Bug Tracker

Side navigation

#12097 closed bug (invalid)

Opened July 17, 2012 04:17PM UTC

Closed July 25, 2012 01:20PM UTC

Last modified July 25, 2012 01:54PM UTC

crossDomain in IE9 is interpreted wrong

Reported by: youcangetme@yahoo.com Owned by: youcangetme@yahoo.com
Priority: undecided Milestone: None
Component: ajax Version: 1.7.2
Keywords: Cc: jaubourg
Blocked by: Blocking:
Description

In jQuery 1.7.2 downloaded today I have to enter the crossDomain value as false in order to get it to do CORS. If FireFox the value only works when set to true.

My ugly workaround is below;

$.ajax({

url: this.dfcore.settings.server+'API/Login.jsp',

type: 'POST',

crossDomain: true == !(document.all),

processData: false,

data: lreq,

success: function(data) {

console.log('Success: '+data);

},

error: function(jqXHR,err) {

console.log(jqXHR.status+": "+jqXHR.statusText);

}

});

Attachments (0)
Change History (11)

Changed July 24, 2012 08:47PM UTC by dmethvin comment:1

component: unfiledajax
owner: → youcangetme@yahoo.com
status: newpending

This isn't enough information for a bug report. Is it actually a cross-domain request? IE9 doesn't support CORS. Can you reproduce in jsFiddle.net, perhaps less the cross-domain request, so we have some real code to use as a starting point for a repro?

Changed July 25, 2012 11:57AM UTC by anonymous comment:2

"Is it actually a cross-domain request? IE9 doesn't support CORS."

Sorry to inform you but IE9 supports CORS. Maybe the reason you think it doesn't is because you have the values backwards in IE? Is this enough information now to consider this a valid bug report? Maybe instead of being a bug its simply a bad implementation?

Changed July 25, 2012 12:05PM UTC by anonymous comment:3

Here you go, IE7 thru IE10 CORS using jQuery! Note that I have to reverse the "crossDomain" value inorder to get it to work, which is the bug or bad implementation I am reporting;

<!DOCTYPE html>
<html>
	<head>
		<title>jQuery CORS in IE7 - IE10</title>
		<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
		<script>
			$(document).ready(function() {
			  $.ajax({
			    url: "http://dreamfactorysql.cloudapp.net/API/index.php",
			    dataType: "text",
					async: true,
					type: 'GET',
					cache: false,
					crossDomain: true == !(document.all),
			    success: function(txt) {
			    	alert(txt);
			    }
			  });
			});
		</script>
		</head>
	<body>
		IE7 thru IE10 CORS Example Using jQuery
	</body>
</html>

Changed July 25, 2012 12:44PM UTC by dmethvin comment:4

Okay you got me there. IE9 supports the CORS protocol via XDomainRequest, just not through a JavaScript API that matches the other browsers. I am assuming you've included that elsewhere?

Your code snippet threads its way through several XDomainRequest limitations such as the inability to specify a content type other than text.

Changed July 25, 2012 12:46PM UTC by dmethvin comment:5

cc: → jaubourg

You mentioned IE7 though, I don't think XDomainRequest works on IE7.

Changed July 25, 2012 01:11PM UTC by youcangetme@yahoo.com comment:6

status: pendingnew

"You mentioned IE7 though, I don't think XDomainRequest works on IE7."

Gotcha Again! Test the code on IE7, IE8, IE9 and IE10 ;-)

If I'm not mistaken, CORS is a Microsoft contribution, like Canvas was from Apple.

Changed July 25, 2012 01:13PM UTC by dmethvin comment:7

Perhaps my copy/paste skills are lacking. Please provide a jsFiddle.

Changed July 25, 2012 01:20PM UTC by jaubourg comment:8

_comment0: http://jsfiddle.net/44yue/3/ \ \ This is, of course, failing in IE9 with an Access Denied error. \ \ That's the reason why we ask for jsFiddle test cases. You have something specific in your environment that enables cross-domain requests (I gather you load the page from the file system). \ \ BTW, the IE9- XHR implementation doesn't support CORS or else https://github.com/jquery/jquery/blob/master/src/ajax/xhr.js#L43 would be true. \ \ You can get IE to accept cross-domain requests but it involves something we do not support: phone app environment, page accessed through the file system protocol (your case most probably), custom security settings, etc. As usual with unsupported environments, you have to use tricks. \ \ Here, what you should do is this: \ \ ``` \ jQuery.support.cors = true; \ ``` \ \ Which is, of course, wrong but close enough for your specific use-case and should take care of all your needs. \ \ Oh, BTW, gotcha.1343222527669895
resolution: → invalid
status: newclosed

http://jsfiddle.net/44yue/3/

This is, of course, failing in IE9 with an Access Denied error.

That's the reason why we ask for jsFiddle test cases. You have something specific in your environment that enables cross-domain requests (I gather you load the page from the file system).

BTW, the IE9- XHR implementation doesn't support CORS or else https://github.com/jquery/jquery/blob/master/src/ajax/xhr.js#L43 would be true.

You can get IE to accept cross-domain requests but it involves something we do not support: phone app environment, page accessed through the file system protocol (your case most probably), custom security settings, etc. As usual with unsupported environments, you have to use tricks.

Here, what you should do is this:

jQuery.support.cors = true;

Which is, of course, wrong but close enough for your specific use-case and should take care of all your needs.

Oh, BTW, gotcha.

Changed July 25, 2012 01:25PM UTC by jaubourg comment:9

Changed July 25, 2012 01:47PM UTC by youcangetme@yahoo.com comment:10

*sigh*

This is an existing app that is being ported to jQuery. It runs currently without any problems and yes, it does cross domain posts and gets. Yes, it doesn't run in other browsers though. I believe the app is 8 years old now? I see a lot of code from 2004 where this cross-domain implementation sits. I would have to check when the owner gets back from Airventure.

I guess what I will do is revert back to the old way since it works without any of these issues. I will simply do a manual "everybody else" branch in execution and role my own.

Changed July 25, 2012 01:54PM UTC by jaubourg comment:11

_comment0: If you set jQuery.support.cors to true, it should work flawlessly, provided you limit yourself to text-only requests (which you probably do since it worked before in plain javascript). I know it sucks but there is a limit to what jQuery can infer without assuming too much. That's why it's so awesome to work on end-products, you can assume so much more ;) \ \ Best of luck for the port :)1343224533632663

If you set jQuery.support.cors to true, it should work flawlessly ((''provided you limit yourself to text-only requests -- which you probably do since it worked before in plain javascript --'' edited because I'm probably confusing with the XDR imp here)). I know it sucks but there is a limit to what jQuery can infer without assuming too much. That's why it's so awesome to work on end-products, you can assume so much more ;)

Best of luck for the port :)