XMLHttpRequest doesn't work as expected on Ionic View App


I’m using XMLHttpRequest to download an image in an ionic app. This works fine when I run the app using ‘ionic serve’ and when I run the app in my iPhone through xcode. However it only sometimes works when I run the app through the ‘ionic view’ app. By sometimes, it seems to only work once if I change the wifi network or restart the phone. And it won’t work again, even if I do subsequent ‘ionic uploads’.

The problem seems to be that when I call the ‘send()’ function of the XMLHttpRequest, the ‘onreadystatechange’, ‘onload’, or ‘ontimeout’ functions are never called (when timeout is set). Have you got any idea why this might be happening?

Thank you.