PhoneGap的/ Android的的WebView抛出"未知铬错误:0" [英] PhoneGap / Android WebView throws "Unknown chromium error: 0"

查看:155
本文介绍了PhoneGap的/ Android的的WebView抛出"未知铬错误:0"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发使用PhoneGap的一个项目,我需要做一个Ajax请求我的本地网络服务器它已经:

PHP code

 头(访问控制 - 允许 - 产地:*');
 

不管怎样,当我做一个Ajax请求与jQuery在Android上我得到这个错误(在亚行logcat):

  D /铬(23078):未知铬错误:0
 

JavaScript的code是:

<$p$p><$c$c>$.ajax({url:"http://192.168.1.219/works/privati/folder/api.php/getlastmaginfo",dataType:"json",success:function(data) {     的console.log(加载完成后由AJAX);     的console.log(数据); }});

在纹波仿真器正常工作,在Android中没了。

任何建议?感谢您的帮助!

更新2013年8月21日:

一些研究我来到那个$就不会与PhoneGap的工作结束后(不知道为什么,也许是一个错误?)。 我们必须使用$。获得,而不是,但是当我做$不用彷徨的请求,我得到未知铬错误:-6 我也看了这里该问题是由于一个Android的错误与web视图的URL机制。

我将继续我的研究,直到我找到一个好工作的解决方案

更新2013年8月21日(2): 甚至没有用这个工程...

  VAR文件传输=新的文件传输();

fileTransfer.download(
    http://192.168.1.219/works/privati​​/qlipmag/api.php/getlastmaginfo
    json.json
    功能(输入){
        的console.log(好);

    },
    功能(错误){
        执行console.log(错误);
    }
);
 

错误是新文件传输(); => 未捕获的Ref​​erenceError:文件传输没有定义

更新2013年8月22日:

甚至通过加载外部图像好好尝试一下工作:

&LT; IMG SRC =htt​​p://externalhost.com/image.jpg/&GT;

同样的错误。

在Android的清单文件我已经设置好的权限:

 &LT;使用-权限的Andr​​oid:名称=android.permission.INTERNET对/&GT;
 

我真的不知道从哪儿来的问题...

更新2013年8月27日: 我试过的PhoneGap一样code的iPhone(在iPhone模拟器)和Ajax请求是全成时,我用了一个外部网站。在Android上使用外部网站上也没有得到相同的结果。 同样的错误。

任何人都可以看到,为什么?访问起源是设置好的细...

解决方案

更新2013年8月27日(1小时后)

问题解决

其实PhoneGap的不使Ajax请求的IP地址,只允许请求白名单(config.xml中)域。 我使用的生产服务器(与域)来测试和它的工作。

感谢你啦家伙。我希望这可以帮助

I'm currently developing a project using PhoneGap and I need to do an ajax request to my local webserver which has already:

PHP code

header('Access-Control-Allow-Origin: *');  

Anyway, when I do an ajax request with jQuery on Android I get this error (in adb logcat):

D/chromium(23078): Unknown chromium error: 0

The Javascript code is:

$.ajax({url:"http://192.168.1.219/works/privati/folder/api.php/getlastmaginfo",dataType:"json",success:function(data)
{
    console.log("Finished loading by ajax");
    console.log(data);
}});

In Ripple Emulator works as expected, in Android nope.

Any suggestion? Thank you for the help!

UPDATE 2013-08-21:

After some researches I came at the conclusion that $.ajax won't work with PhoneGap (don't know why, maybe a bug?). We must use $.get instead, but when I do a request with $.get I get Unknown chromium error: -6 I also read here that the problem is due to an Android's bug with the WebView URL mechanism.

I'll continue my research until I find a good and working solution

UPDATE 2013-08-21 (2): Not even using this works...

var fileTransfer = new FileTransfer();

fileTransfer.download(
    "http://192.168.1.219/works/privati/qlipmag/api.php/getlastmaginfo",
    "json.json",
    function(entry) {
        console.log("OKAY");

    },
    function(error) {
        console.log(error);
    }
);

Error is at new FileTransfer(); => Uncaught ReferenceError: FileTransfer is not defined

UPDATE 2013-08-22:

It doens't work even by loading an external image:

<img src="http://externalhost.com/image.jpg"/>

Same error.

In android manifest file I already setted permission:

<uses-permission android:name="android.permission.INTERNET" />

I don't really know from where comes the problem...

UPDATE 2013-08-27: I tried the same code on PhoneGap for iPhone (in iPhone Emulator) and the ajax request was successfull when I used an external website. Using an external website also on android doesn't get the same result. Same error.

Anybody can see why? Access origin are setted fine...

解决方案

UPDATE 2013-08-27 (after 1 hour)

ISSUE SOLVED

Actually PhoneGap doesn't allows ajax request to ip addresses, it only allows requests to whitelisted (in config.xml) domains. I used the production server (with domain) to test and it worked.

Thank you anyway guys. I hope this can help

这篇关于PhoneGap的/ Android的的WebView抛出&QUOT;未知铬错误:0&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆