2

I am updating a JavaScript file that uses jQuery.support.cors, which is now deprecated;
What should I use instead?

The application operates in an <iframe> inside a parent document and uses $.ajax(); to send data to a different url.

jQuery(document).ready(function() { 
    jQuery.support.cors = true; // This is now deprecated.
}
nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
  • Can you elaborate further to through more light on the context with the affected portion of your code and possible error and or nature of the challenge faced? That will be much of help. – nyedidikeke Oct 21 '16 at 16:31
  • I am working in one particular application that operates in an iframe of a parent page and communicates with other applications across several domains. – fsteverenner Oct 21 '16 at 16:33
  • Please [edit] your question to explain how you're using this property, and any further information that will help people answer your question. – Heretic Monkey Oct 21 '16 at 16:41
  • I guess I don't totally understand how the original method works, but I am also using $.ajax to send data to a particular url. I am guessing that that is why the support.cors was in there in the first place. I am updating the code. – fsteverenner Oct 21 '16 at 16:43

1 Answers1

1

The documentation is pretty helpful here. Firstly that it's intended as an internal collection and secondly it suggests the use of Modernizr instead.

A collection of properties that represent the presence of different browser features or bugs. Intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance. For your own project's feature-detection needs, we strongly recommend the use of an external library such as Modernizr instead of dependency on properties in jQuery.support

Matt
  • 4,107
  • 3
  • 29
  • 38
  • Yes. I saw that on the jQuery documentation. However, I don't want to bring in an external library. I was wondering if there was an updated jQuery method out there or some way of doing the same thing without using support.cors or an external library? Will my code break if I simply remove it? These are my thoughts. – fsteverenner Oct 21 '16 at 16:30
  • The [Modernizr download page](https://modernizr.com/download/?-cors-setclasses) allows you to choose which tests to bring in. I expect that downloading the test for CORS only would result in a very small download. – Heretic Monkey Oct 21 '16 at 16:44