blank error message on errThrown-ajax call - iphone

$.ajax({
url: loginPath,
password: Password,
username: Username,
type: "GET",
error: function(xhr,textStatus,thrownError)
{
alert(textStatus+" "+thrownError);
},
success: function(data)
{
alert(data);
}
});
I am developing an application in Phonegap for iphone & android, my application needs to call web services at a point, now when i call the web service as above, the alert(textStatus+" "+thrownError); show only "error" the thrownError parameter is blank, all this happens when i run the application on the device/simulator, if i run my code on safari it works just fine without any error, but on the device it somehow screws up. Can some1 tell me what i'm doing wrong? or is there any problem with the web services.
P.S: when i say device i mean iPhone 3GS, as of now i am testing it on this device.

Try alert(xhr.statusText); in the error function.

Related

canShareVia invokes the success callback when it should not - iOS 11.2

Description
When the Facebook app is not installed, canShareVia method should invoke the error callback, which is working perfectly with my iPhone5s running iOS 10.
When I test it on iPhone5s running iOS 11.2, it is always invoking the success callback in both the cases where the Facebook app is installed and Not installed.
App
A Cordova mobile app
Plugin: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin
Device information
iPhone 5s
iOS 11.2
Facebook app: Not installed
Sample code
window.plugins.socialsharing.canShareVia('com.apple.social.facebook', 'msg', null, null, null,
function(success) {
do some stuff....
}, function(error) {
alert(error);
});
Please let me know if any work around has been found.
Updated
Found the cause:
This plugin always returns true since iOS11. So we might need another way to detect if there is an app installed and available.
Get it to work with cordova-plugin-appavailability.
You can implement this way (Appavailability plugin to check Facebook app availability and social sharing plugin to do the actual sharing).
appAvailability.check(
'fb://',
function() { // Success callback
window.plugins.socialsharing.shareViaFacebook(...)
},
function() { // Error callback
console.log('Facebook App is not available');
}
);
Though this is a work around but not a fix, this is the only way for now until the fix gets merged to cordova-plugin-x-socialsharing.
You can find the answer for your question here.
App Availability.
Read this and your requirement will be piece of cake.

First ajax attempt miss authorization in header on iphone/ipad

We use windows authentication in our application and it is working fine on our test server. When we publish it onto Production environment (Google compute engine), every first ajax request (per URL) on iPhone/iPad (not matter chrome or safari) after user logon will fail(can not connect to the server). When we perform exactly same action again, it will success. Here is one of our ajax request:
$.ajax({
url: '#Url.Action("GridData")',
type: 'post',
data: {
JobName: $("#JobName").val(),
JobNumber: $("#JobNumber").val(),
},
success: function (data) {
...
},
error: function (xhr, textStatus, errorThrown) {
// first attempt in iPad/iPhone(no matter safari or chrome) will go to here
alert('#Params.AjaxErrorMsg');
},
complete: function() {
...
}
});
After debugging with mac, I found the first ajax call missing the content of Authorization but I have no idea why (this is working fine in any browser with computer version.) Also, I am not sending cross domain request. If I tried to manually put valid data of Authorization for the first ajax call, it will success. Any direction or suggestion will be appreciated. Thanks!

WL.Client.Logout not calling its onSuccess or onFailure callbacks?

Using Mobilefirst Platform 7.1,
I have noticed that logout function has stopped working. I have a browser web app which has a logout button which triggers:
WL.Client.logout("MyAuthenticatorRealm", {
onSuccess: function(res) {
console.log("success server logout"); // Never called :(
WLAuthorizationManager.obtainAuthorizationHeader().then (
function(header) {
// I would reload the app here,
},
function(error) {
...
});
},
onFailure: function(res) {
console.log("failure server logout"); // Never called :(
}
});
But callbacks are never called.
I have checked the sample code from this tutorial and I can see the same thing happening too.
Is there something specific I need to add in 7.1? This used to work in 7.0
EDIT 2015/08/31
There is nothing in the server logs. The client web app seem to be doing a request to authorization/v1/authorization?client_id=XYZ&scope=-MyAuthenticatorRealm&isAjaxRequest=true&x=0.07530371774919331 which returns 200 success.
EDIT 2013/09/17
With the new version (7.1.0.00.20150913-2345) the callback is called! However now I get an exception:
Uncaught ReferenceError: WLAuthorizationManager is not defined
Is this the correct way to do the logout for the latest version? I am trying the "Desktop Browser"
There is a known issue currently in MobileFirst Platform 7.1
APAR PI47591 WL.CLIENT.LOGOUT DOES NOT WORK IN HYBRID PREVIEW
You can open a PMR with IBM to share your interest for this fix, and get updated.

Sencha parses JSON in iphone simulator, but not on iPhone - phonegap

I have the following code in a Sencha Touch App that parses a JSON response from the server.The app is wrapped around Phonegap and being deployed as a native app on the iPhone. This code works fine on the iPhone Simulator but not on the iPhone itself.
There's a similar question already roaming around SO, unanswered: json not loading in iphone device while using sencha touch and phonegap
Ext.Ajax.request({
url: makeurl, //'http://hostname/index.php?id=1234&action=STARTLIST&cmd=0',
scope : this,
success: function(response){
GoRemote.views.devicelist.setLoading(false);
GoRemote.serverstatus="Ok";
Ext.getCmp('serverstatuspanel').update('Server Status : Okay');
this.listData = Ext.decode(response.responseText);
console.log(response);
if (this.listData.listresponse) {
GoRemote.stores.RoomDeviceListStore.loadData(this.listData.listresponse.listdata, false);
GoRemote.views.toolbar.setTitle(this.listData.listresponse.listinfo.listname);
if(this.listData.listresponse.listinfo.container){
Ext.getCmp('btnBack').setVisible(true);
}
else{
Ext.getCmp('btnBack').setVisible(false);
}
}
else if(this.listData.listcontrol){
if(this.listData.listcontrol.controlinfo.name=="NIAVDevice"){
Ext.getCmp('navigation').setActiveItem(0);
}
}
},
failure:function(response){
GoRemote.serverstatus="Unable to reach director";
Ext.getCmp('serverstatuspanel').update('Server Status : Unable to reach director');
GoRemote.views.devicelist.setLoading(false);
}
// timeout:20000
});
Any help will be much appreciated.
So, we managed to fix the error... The server was a custom built and in the Response Headers was responding with HTTP/1.0 where we needed to have HTTP/1.1
Little thing, big impact.
Thanks!

Ajax call to check if native iPhone application exists on the device?

For our iPhone native application we have a URL : example://
On the iPhone if I type this URL (example://) in safari it automatically opens up my application.
From my "regular" website I have a link which when the user clicks it opens the application. The problem is that if the application is not installed on the iPhone it throws "Unable to open" error.
So before rendering the link on my "regular" site I need to check if the app is installed, one solution is to make an Ajax call and check for status code:
$.ajax({
type: 'POST',
url: 'example://',
complete: function (transport) {
if (transport.status == 200) {
alert('Success');
} else {
alert(transport.status);
alert('Failed');
}
}
});
But this code is always returning a status code "0".
Is there a way to find out from the web if the native iPhone app is installed?
If u are referring to Mobile Safari, you're out of luck. There's no documented public API that I know of that can do this. Mobile Safari is sandboxed away from the OS.
If it's in a webview within an app, u can request the URL and let the webview delegate talk to the native app / query the handling of example://. Otherwise, no way the browser can know existence of any installed app.