Closed mathieucarbou closed 10 years ago
I am wondering if it is related to line 570: if I change to
xhr.responseType = req.type || '';
the error disappear, the ajax calls are made but it is like the application code does not receive the ajax body response in json.
Hi @mathieucarbou if that fixes it, I should be able to drop it in. I've only been able to test on safari/chrome/firefox and ie8. I've been meaning to setup automated cross-browser testing though the free services BrowserSwarm and TestlingCI were giving me grief as I needed to setup a static file server and reference it as a different host to simulate cross-domain AJAX.
Not sure what you mean by
application code does not receive the ajax body response in json
So your app is receiving a text response, though its just not an object? or no response at all? does it appear on the network debugger?
Hi,
It does no fix it at alll: it just prevents the error message from displaying, since, according to the spec, is linked to the fact that responseType is not set to a valid value.
So with this fix, we see no error, we also see the ajax request sent and received correctly. But we do not see any callback triggered. I will check again.
I made a test case here to test easily.
Ok i found something.
The fix I made makes things work when issuing ajax requests on the other domain, bridged by xdomain.
But our app also does ajax requests to get a json i18n bundle file from the same domain. This is a simple call like this:
$.getJSON('/locales/' + Locale + '.json', function(i18n){...})
This call is not working with version 0.6 and even with the patched version. With 0.5 it works well.
So it seems to be in the code which detects if it is a normal ajax call or a bridged ajax call I think.
If we set
xdomain.debug = true
we see in the console:
xdomain (http://dashboard-dev.guestful.com): failed to parse url: /locales/en.json
So i patched parseurl function line 785 to replace the null return by:
return {
origin: xdomain.origin,
path: url
};
These 2 fixes make it works on Google Chrome, FF, on desktop. On IOS, the first fix prevents the error message, but the second fix does nothing. The requests does not seem to be sent.
So... it remains IOS now...
I cannot tell if those 2 patches have impatcs elsewhere but they seem to work.
Hi @mathieucarbou sorry for the late reply. @aseemk found the bug: https://github.com/jpillora/xhook/issues/11 In the process of merging into XDomain now...
v0.6 works on IOS 7 as verified,
v0.5 works on IOS 5.1, 6 and 7 but there is the file upload issue...
Error can be displayed on safari using the console.
This is quite a blocking / urgent bug as it prevent xdomin to be used on these IOS versions.
Found this if it can help:
Let us know if we can help / test: the fix is quite urgent for us ;-)