Solved

CORS - IE8 and up with jquery

Posted on 2013-06-03
12
485 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
  • 4
  • 4
  • 4
12 Comments
 

Author Comment

by:JDEE8297
Comment Utility
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 51

Expert Comment

by:Julian Hansen
Comment Utility
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
Comment Utility
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
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
0
 

Accepted Solution

by:
JDEE8297 earned 0 total points
Comment Utility
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 51

Expert Comment

by:Julian Hansen
Comment Utility
@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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
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
Comment Utility
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 51

Expert Comment

by:Julian Hansen
Comment Utility
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
Comment Utility
I agree, however you would not get a job at our company if you do not support ie8. Simple as that.
0
 
LVL 51

Expert Comment

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

Author Closing Comment

by:JDEE8297
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
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)

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now