Solved

CORS - IE8 and up with jquery

Posted on 2013-06-03
12
504 Views
Last Modified: 2013-06-09
I know I asked this before or a question very similar to this one, but this is throwing me for a loop and was wondering if someone has ever experienced this before.

In IE8 my js code that I have in place will work when I call my web-service using localhost:#portnumber from my site which is using localhost:#differentportnumber.

As soon as I try this using domains, then it fails, and for the domains it is myproduct.domain.com (web site) to api.domain.com (my web service) where domain.com is the same domain name. It doesn't get to the service call, and throws an access denied message as it attempts to make the call.

Any ideas on why this is working like this.


   $.support.cors = true;
    $.ajax({
        type: "post",
        url: strUrl,
        
       contentType: "application/json; charset=utf-8",
       //contentType: 'text/plain',
        data: JSON.stringify(jsonObject),
        //beforeSend: function (xhr) {
            //xhr.setRequestHeader("sidw-token", getToken());
        //},
        crossDomain: true,
        success: function (msg) {
         //   alert(JSON.stringify(msg[0]));
            successDisplayPatientList(msg);
        },
        error: function (msg) {
            alert(JSON.stringify(msg));
            
        }
    });

Open in new window

0
Comment
Question by:JDEE8297
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 4
12 Comments
 

Author Comment

by:JDEE8297
ID: 39216471
this is the originally question on the subject.

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28140964.html

but I had reverted this back to my original approach, because I saw it working on the localhost:#portnumber scenario, and from what I understand that is the same thing using the domain approach.
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39218279
My recommendation - save yourself some time and don't support non-compliant browsers.

IE8 has < 5% of the browser market see my rant here for more http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/CSS/Q_28145902.html
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39218625
Julian: That is a very nonchalant suggestion. I work for an organisation with 8000 internal users, all on IE8 and no way to change that in the foreseeable future. All our code supports IE8+ and until very recently IE6 too
0
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39218635
0
 

Accepted Solution

by:
JDEE8297 earned 0 total points
ID: 39218730
Julian: I really dont care how much of the marketshare the browser has, but if the majority of my users who come to the site are using IE8 and above, then I have to support that marketshare and it is alot more than 5%.

As a developer we can't choose what we support and don't support when it comes to web development, if that was the case, then we would need all of our respecive visitors to upgrade to the latest and greatest version of all browsers. However, we all know that is not going to happen because of users from corporations who are stuck on some old browser version because of legacy or internal upgrade path.

The only IE version that I refuse to support in this day and age is IE6 and more recently leaning towards dropping IE7 support as well. All of this is based on my analytics of the visitors to our site.

mplungjan: Yep, already came across that one in my research, turns out I was able to finally get it to work. I used XDomainRequest and checked to see if the browser was IE or not, if IE then XDOmainRequest and if not then continue the ajax jquery route.
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39218903
@mplungjan that is an internal issue and it does not change the fact that IE8 must go.

If you have a specific project that has to support IE8 then that is different but for websites out in the wild time spent getting non-compliant browsers to work is a waste and it gives MS license to continue producing inferior software.

Organisations that are still running IE8 should be more proactive and move onto a more compliant browser - the trend is that their users are in an insignificant minority and catering to < 5% of users has no value at all.

Disagree if you will but I lost too many (unpaid) hours of my life because of IE rubbish and it is time that browser dissappeared or became 100% standards compliant - I don't care which as I do not support IE - if my sites work on IE great - if not I don't care.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39218920
great for you that you have the luxury. Others do not. Does not matter how much I agree with you. My management does not.
0
 

Author Comment

by:JDEE8297
ID: 39218981
Julian: I agree with you that IE support needs to be down the latest version of the browser, and regardless if it is in the wild, you have to based your browser support on your analytics or at least use that as  guideline.

Example: ecommerce site
If 80% of your traffic is coming from IE8 and that works out to be about 1 to 2 million in sales, and you decide that you are only going to support standards compliant browsers and not IE8. Then you may get a percentage of that to switch over, but people are lazy or as I mentioned above...don't have the option to switch to the newest browser.

I am glad you have the luxury to choose what you support or dont support, but you have to be smart about how you cut off people on old browsers.

I have being doing this a long time, and have heard all of the stories about how IE sucks and so on, and we should do everything in Chrome or Firefox and so on. However, at the end of the day the customer is always right....no matter how much that makes your job a PITA to support old browsers.
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39220499
If 80% of your traffic is coming from IE8

If pigs could fly ...

Reality is 80% of any traffic is highly unlikely to be from IE8 users - and definitely not worth 1-2million in sales. You can get around any argument with unrealistic assumptions.

IE8 is a speedbump - support it if you wish - it is your time - I am joining the growing group of developers who refuse to be dictated to by MS on how we want to code and how we want to spend our time.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39221068
I agree, however you would not get a job at our company if you do not support ie8. Simple as that.
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39221271
@mplungjan - would not even consider applying - I work with people who live in the future not the past.
0
 

Author Closing Comment

by:JDEE8297
ID: 39232711
It is the only way to make this work in older IE versions (not sure about IE7 and below, but I am not supporting those versions for my site).

Using XDomainRequest and it works like a charm
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question