0

I'm current working on some stuff that need to send cross-domain ajax requests. I'm using jQuery 1.7.2 and Resteasy. Here is my ajax request:

 $.ajax({ url: Configuration.AjaxUrlPrefix + "/rest/conf/saveoption", data: { save_option: JSON.stringify(optionData) }, type: "POST", dataType: 'text', success: success, error: fail, cache: false }); 

And I use a interceptor to add some headers to my rest responses:

@Provider @ServerInterceptor public class CrossDomainInteceptor implements PostProcessInterceptor { @Override public void postProcess(ServerResponse response) { MultivaluedMap<String, Object> metadata = response.getMetadata(); metadata.add("Access-Control-Allow-Origin", "*"); metadata.add("Access-Control-Allow-Methods", "*"); metadata.add("Access-Control-Max-Age", "*"); metadata.add("Access-Control-Allow-Headers", "*"); } } 

It works well in Chrome and FF, but not work in IE8 and IE9. And I didn't see any error in IE developer tool. Could anyone help me?

1 Answer 1

1

IE8-9 should use XDomainRequest to fire cross-domain ajax request and jQuery does not support it natively, I find a ticket on jQuery bug tracker: http://bugs.jquery.com/ticket/8283

jQuery team may consider XDomainRequest not completely compatible to its ajax interface so has decided not to support it, however a plugin may be helpful: https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js

Remember xdr transport has some limitation, check discussion of the jQuery ticket above

Sign up to request clarification or add additional context in comments.

2 Comments

Esp. XDomainRequest has some limitations as it doens't support credentials.
@otakustay Thanks, the xdr plugin works for my Get requests but not Post request, I'm still working on it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.