Since I add the following lines to mij jQuery script, the whole jQuery is not working anymore on Mobile Devices. On all the PC browsers everything works fine
if ( $("input[name=campaign_id").val() ) {
$('#address').load('/Xscripts/fetch_users_data.php?cid=' + $("input[name=campaign_id").val(), function(responseTxt, statusTxt, xhr){
if(statusTxt == "error")
alert("Error by loading data: " + xhr.status + ": " + xhr.statusText);
});
};
There is no error message, but just all the jQuery functions are completely not working.
Does anyone have any clue how to fix this? How can this load code make the complete jQuery-script crashing on iPhone and Android? Removing these lines makes the rest of the script running again.
Many thanks in advance,
NiFa
OK lets try some things
1st close input attr with ] .. replace a next code in both places
$("input[name=campaign_id]").val()
------^------
2nd for load url you can try
'Xscripts/fetch_users_data.php?cid=' + $("input[name=campaign_id]").val()
or
'./Xscripts/fetch_users_data.php?cid=' + $("input[name=campaign_id]").val()
hope it helps
Related
I am trying to check disk space available in mobile using below code:
cordova.exec(function(result) {
var diskSizeInMB = result/1024;
alert(diskSizeInMB)
}, function(error) {
alert("Error: " + error);
}, "File", "getFreeDiskSpace", []);
In Android device it gives me correct result, whereas if I use iPhone/iPad it always returns me 0 as a output. Can anyone guide me how to resolve this issue? Or is there a way to check the disk size in iOS using cordova without writing custom plugin? To make this happen I haven't changed any configuration changes
It was a bug, but was fixed long time ago.
Old answer:
I confirm there is a bug on the code, the problem is getFreeDiskSpace is undocumented and cordova team want to remove the native code as getFreeDiskSpace isn't part of the w3c file API.
If you want to fix the bug for you app, go to CDVFile.m and change the line
NSNumber* pNumAvail = [self checkFreeDiskSpace:self.appDocsPath];
to
NSNumber* pNumAvail = [self checkFreeDiskSpace:self.rootDocsPath];
on the getFreeDiskSpace method
I'm trying to get the ID of a mobile phone where my hybrid worklight (v6.2) app is running on and the app is hanging on the following code:
WL.Logger.log("About to getID...");
WL.Client.getID({onSuccess : function(o) {
WL.Logger.log("getID: " + o);
devID = o.deviceID;
}, onFailure : function(e) {
WL.Logger.log("Error getting ID: " + e);
}});
WL.Logger.log("After getID...");
I see the "About to getID" output in the LogCat log, but that is it. I never see the onSuccess logging nor the onFailure logging. And the "After getID" logging never appears either.
From reading the Knowledge center documentation, it doesn't appear this method is making a call back to the Worklight server at all. This has failed both in an Android emulator and on an Android device.
Any suggestions/insight to get this method to work would be appreciated.
If you will look at the API reference for Worklight 6.2, you will see there is no such API method as WL.Client.getID: http://www-01.ibm.com/support/knowledgecenter/#!/SSZH4A_6.2.0/com.ibm.worklight.apiref.doc/html/refjavascript-client/html/WL.Client.html?cp=SSZH4A_6.2.0%2F10-0-0-1-6
There is however WL.Device.getID: http://www-01.ibm.com/support/knowledgecenter/#!/SSZH4A_6.2.0/com.ibm.worklight.apiref.doc/html/refjavascript-client/html/WL.Device.html%23getID
I've been stuck here for quite some time now. I am developing a mobile application with phonegap. I have tested the app with android 4.0.4 and it is working perfectly fine. However, when I tested on 2.2.3, the AJAX ended with and error state of:
ready state = 0
HTTP Status = 0
I have tried to increase the timeout to be really long but it still ends with that result. I am not sure what is the problem but I have developed another app using the same ajax call and it is working fine on android 2.2.3 but what makes this time different is that it calls to a SAML URL (Identity Provider).
the codes is like bellow:
$.ajax({
url: "...."+Math.random(),
type: "POST",
data: {
j_username: uname,
j_password: pword
},
cache: false,
timeout: (100*1000),
success: function(data, textStatus, jqXHR){
var contentType = jqXHR.getResponseHeader('Content-Type');
if (contentType == 'application/atomsvc+xml'){
}else{
alert(".....");
// clearTimeout(timer);
$.mobile.hidePageLoadingMsg();
enableAllButtons();
}
},
error: function(jqXHR, textStatus, errorThrown){
// clearTimeout(timer);
alert("Error Thrown : " + errorThrown);
alert("status : " + jqXHR.status + " " + jqXHR.statusText);
alert("ready state : " + jqXHR.readyState);
alert(".......");
$.mobile.hidePageLoadingMsg();
enableAllButtons();
}
});
Really hope someone can help me with this.
Thank you very much for your input in advance.
Regards,
Amanda
The code seems to be fine except one thing
You are using Math.random() in the URL.. You also use cache:false
Try to remove the Math.random() from URL while jQuery Cache uses the same thing.
Also, while you get readyState = 0 then it will be a CrossDomain issue. Use JSONP for that (dateType:'JSONP') in AJAX options
I have an HTML/JavaScript app that I'm trying to convert to an App using PhoneGap via the Phonegap Build app
Everything works fine through the browser, and the only problem the app is having is that the call to getJSON is returning a 404 error when trying to load my local resources.
Here is the culprit:
$.getJSON( "./shapes/json/" + abbr + '.json', gotJSON(abbr) );
I have whitelisted every domain, just to be sure:
<access origin="*" />
Is this something that is not possible from the phonegap environment? Or am I doing something wrong?
If needed, I can host the files elsewhere and do a cross-domain ajax call, but I'd rather have the files right there on the device.
This is currently happening on Android, which is the only system I can test at the moment.
UPDATE:
I'm now trying:
var xhrShapes = new XMLHttpRequest(), xhrSuccess = gotJSON(abbr);
xhrShapes.open('GET', config.path + "/shapes/json/" + abbr + ".json");
xhrShapes.onreadystatechange = function(e){
if( this.readyState === 4 ){
if( this.status === xhrSuccessCode ){
xhrSuccess(JSON.parse(this.responseText));
}
}
}
xhrShapes.send();
config.path is "file:///android_asset/www" and I'm getting 0 as a success code (which indicates success for 'file://' requests). but xhrShapes.responseText is blank and everything stops at the call to JSON.parse. I feel like I'm missing something simple...
The problem had nothing to do with the code, but rather with the file names being case-sensitive... my abbr variable was uppercase, but filenames are lowercase. $.getJSON works perfectly, now that I've corrected this (though now my pride needs some repairs).
It took me for the whole day to figure out this problem. I am working on a webapp (using Phonegap + HTML + jQuery + CSS).
It consists of one screen, which displays user signatures.
I used the same .js file which is used in iPhone and in that the signature image is appearing without any problem, but the same code is not working on Android (I tried using Android 2.2.1, 2.3.3, 3.0 and 4.0) But nothing works.
Following is the code snippet from my .js file :
SignatureButtonThumbComponent.prototype.setInitialValue = function () {
var date, value;
value = this.record.valueForField(this.config.key);
//value = window.btoa(this.record.valueForField(this.config.key)); // Not Working
console.log("Signature Value : " + value);
console.log("Signature Date value : " + date);
date = this.record.valueForField(this.config.key_date);
if (value !== 'undefined') {
this.el.append("<button class='captured_signature_button'><img src='" + value + "'/></button>");
if (date) {
return this.el.append("<div class='signature_date'>" + (Formatter.timeFormattedNicely(date)) + "</div>");
}
} else {
return this.el.append("<button class='big blue arrow_button' id='get_patient_signature'><span>" + this.config.button_label + "</span><span class='icons arrow_right'></span></button>");
}
};
EDIT: Following is my logcat output :
09-21 12:01:19.562: D/PhoneGapLog(1362): Signature Date value : undefined
09-21 12:01:19.672: D/PhoneGapLog(1362): Signature Value : undefined
After Figuring little more, What Now I am getting in logcat is this :
09-21 16:33:27.947: D/PhoneGapLog(948): file:///android_asset/www/new_mobile.js: Line 15790 : Signature Value : data:,
Finally after the whole day's run, I found the solution.
Basically Android does not support canvas of HTML5, though it claims for the same.
Whenever I tried to save paint of canvas object, I got data:, meaning null as an output.
Here is a nice js, which you can use to override the default method of canvas.toDataURL().
The only drawback to this js is that its comparatively slow to save your graphic. But as of my situation, its well suited and I integrated it in my jquery. You can find this js here : http://code.google.com/p/todataurl-png-js/