Android的ICS 4.0.3本地阿贾克斯不工作 [英] Android ICS 4.0.3 Local ajax doesn't work
问题描述
我有一个网页视图Android应用和web视图使用jQuery
在web视图的JS获取本地文件加载模板
使用以下code:
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);
});
这code从来没有工作,我总是得到未知铬错误:-6
This code never works and I always get unknown chromium error: -6
发生在ICS 4.X此错误,并在升级Froyo正常工作,姜饼,蜂窝和
This error happens on ICS 4.X and works normally in Froyo, Gingerbread, and Honeycomb
我也试过这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;
}
});
更新:
我找到了一个解决方案/办法解决这个问题(这没有意义了)
解决的办法很简单:在本地加载的文件不能包含单引号,我不知道为什么,但改变所有的单引号双引号解决了这个问题。
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
推荐答案
我找到了一个解决方案/办法解决这个问题(这没有意义的)解决方案很简单:在本地加载的文件不能包含单引号我不知道为什么,但改变所有的单引号双引号解决了这个问题。
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.
- 同时改变缓存:假缓存:真或只是将其删除
这篇关于Android的ICS 4.0.3本地阿贾克斯不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!