Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

John Moya
17,963 PointsAJAX Request Question
Does anybody knows what to add to an ajax Request to allow it to be CORS compatible?
1 Answer
Igor Yamshchykov
24,397 Pointsyou can use JSON with padding request for instance in jQuery you might use
$.getJSON(url, data, success )
url is url you want to send request to, data is object with data that will be sent with request, and success is callback function that will occur on success, you can also use .done method to trigger success call back and .fail method to trigger error like so
$.getJSON(url, data, success ).done(functionDone).fail(functionFail);
you pass functions to those methods.
Note that not all the sites allows you to do cross-domain requests.
You also can find more at the jQuery documentation, about this methods, along with examples.