NETWORK_ERR:XmlHtt prequest异常101的Andr​​oid异常、prequest、XmlHtt、NETWORK_ERR

由网友(丿那年丶花开花落)分享简介:我开发的移动应用程序的Andr​​oid mobile.When永远我运行它,我得到了以下错误:network_err xmlhtt prequest异常101。任何人都可以请你澄清?我使用的是Android 4.2版下面code是code在mainActivity.java文件:包com.example.myE...

我开发的移动应用程序的Andr​​oid mobile.When永远我运行它,我得到了以下错误:network_err xmlhtt prequest异常101。 任何人都可以请你澄清? 我使用的是Android 4.2版 下面code是code在mainActivity.java文件:

 包com.example.myExample;

进口org.apache.cordova.DroidGap;
进口android.os.Bundle;

公共类MainActivity扩展DroidGap {

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        super.loadUrlTimeoutValue = 15000;
        super.loadUrl(文件:///android_asset/www/index.html);

        。appView.getSettings()setAllowUniversalAccessFromFileURLs(真正的);
    }
}
 

解决方案

跨域XMLHtt prequest?我和其他人都被这(貌似无证除外)时做跨域XMLHtt prequests。你让大多数的请求与XMLHtt prequest将跨域(即服务器不是从中加载的HTML页面外,其它) - 因为你从加载所访问本地文件系统(文件:安卓/ Webkit内核可以有一些白色列出的域,但是这可能不是你想要做什么。

通常情况下跨域使用XMLHtt prequest(这仅被允许在最近几年),要求你要,许可的请求的服务器。访问控制 - 允许 - 产地:这是通过服务器返回的HTTP标头进行*(等,请参阅有关跨域XMLHtt prequest信息)

我已经看到了这个异常出现在Android 2.3.5 / Webkit的553.1与已经被重复有效的跨域请求(缓存错误?)。其他人曾经说他在跨域请求,其中反应是无效的XML。

检查什么协议(HTTP VS HTTPS等)什么主机和哪个端口(通常为80),您试图发送请求。

I am developing a mobile application for android mobile.When ever I run it I get the following error: network_err xmlhttprequest exception 101. Can anyone please clarify? I am using Android version 4.2 The below code is the code in mainActivity.java file:

package com.example.myExample;

import org.apache.cordova.DroidGap;
import android.os.Bundle;

public class MainActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrlTimeoutValue = 15000;
        super.loadUrl("file:///android_asset/www/index.html");

        appView.getSettings().setAllowUniversalAccessFromFileURLs(true);
    }  
}

解决方案

CrossDomain XMLHttpRequest? I and others have been this (seemingly undocumented exception) when doing cross domain XMLHttpRequests. Most requests you make with XMLHttpRequest will be cross domain (ie to a server other than the one from which the HTML for the page was loaded) -- because the domain you loaded from is the local file system (file:) Android/Webkit can have some white listed domains, but that is probably not what you want to do.

Typically cross domain use of XMLHttpRequest (which has only been permitted in recent years) requires that the server that you are going to, permits the request. This is done by having the server return an HTTP header: Access-Control-Allow-Origin: * (etc, See information about cross domain XMLHttpRequest)

I've seen this exception show up on Android 2.3.5/Webkit 553.1 with valid cross domain requests that have been repeated (caching bug?). Others have reported it on cross domain requests where the response was invalid XML.

Check what protocol (http vs https, etc) what host and what port (usually 80) you attempting to send requests to.

阅读全文

相关推荐

最新文章