jpillora / xdomain

A pure JavaScript CORS alternative
https://jpillora.com/xdomain/
3.12k stars 270 forks source link

sync xhr not supported by XHook (Bootstrap) #90

Closed rafaelfernandezgis closed 10 years ago

rafaelfernandezgis commented 10 years ago

I am using your XDOMAIN code in my project. I have published a web service: http://map.stjohns.ca/CSJMSGovernWebServiceDMZ/CSJMSGovernWebServiceDMZ.asmx

And I am consuming it using AJAX. The initial stage of this project is only getting street names from an autocomplete text box (right-top). You can see it here (you can type Water St.): http://jsfiddle.net/nuR8G/embedded/result/

In this project, I am using JQuery mobile and as far as you can see, the XDOMAIN code works pretty well. The application is communicated with the server and this returns right results.

But this application is not only for mobile devices, it is even for desktop use. For this reason I am trying to forget to JQuery Mobile and I started to use a twitter Bootstrap template since it has more flexibility. However, I am getting the next error from the XDOMAIN code: xhook is not defined (xdomain.min.js)

You can see it here: http://jsfiddle.net/hLp8P/5/

Please, do you have any clue about the reason that XDOMAIN is not working on a Bootstrap template?

Thanks for your time and congrats for your code!!

rafaelfernandezgis commented 10 years ago

Looking for the forums, I found the problem. You need adding this line: window.xhook = xhook;

after: xhook = EventEmitter(true); and before: xhook.EventEmitter = EventEmitter;

Hopefully it helps somebody else.

Cheers, Rafael

jpillora commented 10 years ago

Hi Rafael, sorry for the late reply. This seems to be caused by requirejs/amd. Will close this and track this bug on #91

jpillora commented 10 years ago

This should be fixed now, see http://jpillora.com/xdomain/example/requirejs/