Returning A Value From Cordova File Plugin When Called From A Function
I have seen someone has posted a similar question but it doesn't really fit what I'am looking for: Here is my code: $(document).ready(function(){ $('#btnTest').bind('click', func
Solution 1:
I would create a global variable in your function called returnValue
and set its value
$(document).ready(function(){
$("#btnTest").bind("click", function(){
a = createFile();
alert(">> "+a); // Displayed returned value;
});
function createFile(){
var returnValue;
var type = window.TEMPORARY;
var size = 5*1024*1024;
window.requestFileSystem(type, size, successCallback, errorCallback)
function successCallback(fs) {
fs.root.getFile('log.txt', {create: true, exclusive: true}, function(fileEntry) {
alert('File creation successfull!');
returnValue = 1; // Return value;
}, errorCallback);
}
function errorCallback(error) {
alert("ERROR: " + error.code)
returnValue = 2; // Return value;
}
return returnValue;
}
});
Post a Comment for "Returning A Value From Cordova File Plugin When Called From A Function"