XMLHttpRequest Exception 101 in hybrid mobile application - javascript

I have a hybrid mobile application which works on both android and ios devices.
The problem with it is that the application works fine when run on Android. However, there is a Network Error: XMLHttp Request Exception 101: saying server is unresponsive while running the application in iOS.
The application uses Cordova 2.9
I have been trying out solutions like setting async to true(initially it was false). But it does not solve my issue.
Can you please tell me the reason and the solution to be provided.
Thanks.

Make sure that you are using JSONP data format in IOS. This same as Json, but a callback function is needed.

Related

React app works fine but not on mobile browsers

My react-redux app works fine on regular browsers but not on mobile browsers. I've used Remote Debugging on Android Devices to check what's going on and I get these 2 errors:
OPTIONS http://iisnode.local/login 0 ()
Uncaught (in promise) TypeError: Failed to fetch
The app makes many fetch requests but I'm afraid that fetch is not supported by chrome mobile. Any help would be much appreciated.
Looks like a CORS problem. Make sure the protocol for your requests is "HTTPS". If you are using Node, in your server.js code, use the standard CORS npm package.
Chrome for Android, version 42 onwards supports the fetch API. Why aren't you using error handling if the promise is rejected anyway

Android only: net::ERR_INSECURE_RESPONSE

I have a web application that makes a lot of ajax calls and opened up headers to allow cross domain.
Failed to load resource: net::ERR_INSECURE_RESPONSE
I get this error in the console when I try to call on android devices. When I test on apple devices and browsers, it works fine.
My initial guess is that despite it only happening in Android, it's still a certificate issue but wanted to get thoughts on why this is happenning on Android only and not iOS and desktop.

Unable to connect to websocket

I have a cordova/phonegap app that is supposed to connect itself to a websocket server. It works fine on ios & android 4.4 but not on my Samsung Galaxy Tab 2 running android 4.2.
I know that the webview in 4.2 doesn't have a native implementation of WebSockets but I loaded a phonegap plugin for this. The plugin loads successfully and I waited for the deviceready event before attempting a connection. When I try the example provided by the plugin, the onerror event is trigered but I have no additionnal details.
Running the app using Google Chrome on the same device works, so I exclude a network issue. The application has the INTERNET permission. I'm a little out of clues at this point, any ideas are welcome :-)
Ok, after taking a look at the adb log as #Nicholas suggested (thanks!) I had an exec() call to unknown plugin. Somewhat following this answer solved the problem.

jQuery $.get doesn't work for "local" files in Phonegap or Mobile Safari

I have a templating system I was trying to use with my Phonegap App that utilizes jQuery and the $.get() function.
$.get('templates/' + name + '.html', someFunctionHere(){});
When I run the app as a server on localhost and view it through Chrome or Safari the templating system works perfectly.
When I run the app through Phonegap on the iOS Simulator, it doesn't work. No file is returned and "someFunctionHere()" doesn't run.
Important note: When I use Mobile Safari under the iOS Simulator to view the page served by my localhost it also does not work.
To me, this sounds like the WebKit browser that Mobile Safari and Phonegap use won't allow access to local files? This feels completely incorrect but that's how it looks.
Has anyone encountered this problem before, or know of a way to get around it?
I think safari does not support async call which is on by default and you need to turn off async mode in order to get it worked in safari.
Might be related to: http://developer.mozilla.org/en/http_access_control
Instead of using localhost access the files from the file:// protocol and it should work, it's a cross domain restriction in Safari / Mobile Safari.
Did you try to set the type parameter of $.get to 'text'? That worked for me. If you don't $.get will try to guess it and in my case it guessed it wrong.

SignalR on mobile web?

I'm evaluating SignalR technology for use in our new product (mobile web application for the broad audience, among other things it needs a real-time chat on some pages).
I've followed the guide to create a very basic chat demo.
Then I deployed the demo on my IIS, and started chatting to myself.
All clients were on the same WiFi network.
Desktop browsers worked more or less OK.
However, Safari on iOS 4.2, and IE on WP7.10 - they both sucked.
Sometimes nothing happened when I pressed the "post" button.
Sometimes outgoing messages were sent OK to the desktop firefox, however there was no incoming messages.
Maybe I'm missing something obvious? Maybe I need jquery mobile instead of the normal one? Maybe I should just tune the IIS/web.config/whatever, and the SignalR will flourish and start to work flawlessly even through the crappy mobile internet?
Or does it mean that since it doesn't work even while on WiFi within a single hop from the web server, I should throw SignalR away and just write some JavaScript to poll a JSON endpoint for new messages?
Thanks in advance!
I have been developing an app with phonegap (that means that uses the Safari browser) and SignalR for Android and IPhone. The major issue I had was with iOS 6.x because SignalR did not connect with default config. I have found a workaround for that and I had explained it here. Let me know if you find it useful.
This code will simulate a connect, check for messages, disconnect and wait 5 secs to solve the iOS issue.
In js add
$.connection.hub.start({ transport: 'longPolling' }).done(function (myHubConnection) { });
and in Application_Start() add
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
Microsoft.AspNet.SignalR.Transports.LongPollingTransport.LongPollDelay = 5000;
RouteTable.Routes.MapHubs();
Not all mobile browsers (e.g. android, opera mini) support websockets. You'll find a nice chart of supporting browsers at http://www.hanselman.com/blog/YourUsersDontCareIfYouUseWebSockets.aspx

Categories