Issue
I have an android app with Webview and uses JQuery in the webview The JS in the webview fetches a local file to load templates using the following code:
$.get("file:///android_asset/www/templates.html",function(data){
$("#templates").html(data);
});
This code never works and I always get unknown chromium error: -6
This error happens on ICS 4.X and works normally in Froyo, Gingerbread, and Honeycomb
I also tried this code:
$.ajax({
url : "file:///android_asset/www/",
type:"get",
data : null,
cache:false,
success:function(data){
activity.doLog("Got it to work"); // This refers to Log.d in activity
return false;
},
error:function(xhr,msg,thrown){
activity.doLog("Didn't get it '"+msg.replace("\n"," --- "));
// Logged error here is 'error
// Which is meaningless message
return false;
}
});
Update:
I found a solution/workaround for this problem (that doesn't make sense at all) The solution is simply: the locally loaded file must not contain single quotes, I don't know why but changing all the single quotes to double quotes solved the problem
Solution
I found a solution/workaround for this problem (that doesn't make sense at all) The solution is simply: the locally loaded file must not contain single quotes, I don't know why but changing all the single quotes to double quotes solved the problem.
- Also change cache: false to cache: true or just remove it
Answered By - Shehabic
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.