科尔多瓦/ PhoneGap的所有外部的Ajax请求,则返回404 [英] Cordova / Phonegap All External Ajax Requests Returns 404

查看:143
本文介绍了科尔多瓦/ PhoneGap的所有外部的Ajax请求,则返回404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也有一个科尔多瓦3.3应用程序,但昨天我更新的科尔多瓦和我所有的应用程序插件的Apache的科尔多瓦V5.0。

因为我做到了,我把闪屏插件,并没有任何问题建立我的应用程序,但是当我试图测试,我看到的所有外部Ajax请求返回的 404错误,其中包括一个简单的Ajax请求,以谷歌。


一切工作正常,在任何浏览器。


我的config.xml文件:

 < preference名=闪屏的价值=屏幕/>
< preference名=SplashScreenDelay值=6000/>
< preference名=SplashMaintainAspectRatio值=真/>

<平台名称=机器人>
    <飞溅SRC =屏/安卓/ ldpi.9.png密度=LDPI/>
    <飞溅SRC =屏/安卓/ mdpi.9.png密度=MDPI/>
    <飞溅SRC =屏/安卓/ hdpi.9.png密度=华电国际/>
    <飞溅SRC =屏/安卓/ xhdpi.9.png密度=xhdpi/>
< /平台>

< preference名=日志级别值=DEBUG/>
< preference名=AndroidLaunchMode值=singleTop/>
< preference名=ErrorUrl值=/>
< preference名=莫尼卡:DisableCookie值=FALSE/>
<功能名称=应用程序>
    < PARAM NAME =Android的包值=org.apache.cordova.App/>
< /功能>
< preference名=莫尼卡:androidVersion code值=1/>
< preference名=KeyboardShrinksView值=真/>
< preference名=莫尼卡:MonacaBackendUrl值=htt​​ps://cloud.monaca.mobi/json-rpc//>
< preference名=莫尼卡:MonacaBackendId值=5462a7b9fd1734575d0f0317/>
< preference名=莫尼卡:MonacaBackendApiKey值=e839514dc867719689001fa1c32a17136adeb1ba631c5885b2f996b1375f9cb4/>
< preference名=KeepRunning值=真/>
< preference名=莫尼卡:AndroidIsPackageNameSeparate值=FALSE/>
< preference名=DisallowOverscroll值=真/>
< preference名=莫尼卡:WebViewEngine值=默认/>
< preference名=方向值=画像/>
< preference名=全屏值=FALSE/>
< preference名=BackgroundColor中值=0xff1b3c81/>

<获得原产地=*/>
 

我的Andr​​oidManifest.xml

 < XML版本=1.0编码=UTF-8&GT?;
<舱单安卓hardwareAccelerated =真的Andr​​oid版本:版本code =1机器人:VERSIONNAME =0.0.1机器人:windowSoftInputMode =adjustPan包=com.nowa的xmlns:机器人=HTTP ://schemas.android.com/apk/res/android>
    <支持屏安卓anyDensity =真正的机器人:largeScreens =真正的机器人:normalScreens =真正的机器人:调整大小=真正的机器人:smallScreens =真正的机器人:xlargeScreens =真/>
    <应用的Andr​​oid版本:hardwareAccelerated =真正的机器人:图标=@可绘制/图标机器人:标签=@字符串/ APP_NAME>
        <活动机器人:configChanges =定位| keyboardHidden |键盘|屏幕尺寸|语言环境机器人:标签=@字符串/ APP_NAME机器人:launchMode =singleTop机器人:NAME =诺瓦机器人:screenOrientation =肖像机器人:主题=@安卓风格/ Theme.Black.NoTitleBar>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>
                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>
    <使用-SDK安卓的minSdkVersion =10机器人:targetSdkVersion =19/>
    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用-权限的Andr​​oid:名称=android.permission.RECORD_AUDIO/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_COARSE_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.MODIFY_AUDIO_SETTINGS/>
    <使用-权限的Andr​​oid:名称=android.permission.READ_PHONE_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.RECORD_VIDEO/>
    <使用-权限的Andr​​oid:名称=android.permission.VIBRATE/>
< /舱单>
 

的Ajax请求一个例子,不工作:

  $。阿贾克斯(http://www.google.com.br)
        .done(函数(){
            警报(成功);
        })
        .fail(函数(){
            警报(错误);
        })
        。总是(函数(){
            警报(完成);
        });
 

解决方案

科尔多瓦5.0个街区外的http请求默认情况下。

尝试增加科尔多瓦 - 插件白名单到您的项目。

I did have a Cordova 3.3 app, but yesterday i update the cordova and all my app plugins to v5.0 of apache cordova.

Since i did it, i put a splash screen plugin and build my app without problems, but when i tried to test, i saw that all external ajax requests returns a 404 error, including a simple ajax request to google.


Everything works fine on any browser.


My config.xml:

<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="6000" />
<preference name="SplashMaintainAspectRatio" value="true" />

<platform name="android">
    <splash src="screen/android/ldpi.9.png" density="ldpi"/>
    <splash src="screen/android/mdpi.9.png" density="mdpi"/>
    <splash src="screen/android/hdpi.9.png" density="hdpi"/>
    <splash src="screen/android/xhdpi.9.png" density="xhdpi"/>
</platform>

<preference name="loglevel" value="DEBUG"/>
<preference name="AndroidLaunchMode" value="singleTop"/>
<preference name="ErrorUrl" value=""/>
<preference name="monaca:DisableCookie" value="false"/>
<feature name="App">
    <param name="android-package" value="org.apache.cordova.App"/>
</feature>
<preference name="monaca:androidVersionCode" value="1"/>
<preference name="KeyboardShrinksView" value="true"/>
<preference name="monaca:MonacaBackendUrl" value="https://cloud.monaca.mobi/json-rpc/"/>
<preference name="monaca:MonacaBackendId" value="5462a7b9fd1734575d0f0317"/>
<preference name="monaca:MonacaBackendApiKey" value="e839514dc867719689001fa1c32a17136adeb1ba631c5885b2f996b1375f9cb4"/>
<preference name="KeepRunning" value="true"/>
<preference name="monaca:AndroidIsPackageNameSeparate" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="monaca:WebViewEngine" value="default"/>
<preference name="Orientation" value="portrait"/>
<preference name="Fullscreen" value="false"/>
<preference name="BackgroundColor" value="0xff1b3c81"/>

<access origin="*"/>

My AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" android:windowSoftInputMode="adjustPan" package="com.nowa" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:launchMode="singleTop" android:name="Nowa" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECORD_VIDEO" />
    <uses-permission android:name="android.permission.VIBRATE" />
</manifest>

A example of ajax request that doesn't work:

$.ajax( "http://www.google.com.br" )
        .done(function() {
            alert( "success" );
        })
        .fail(function() {
            alert( "error" );
        })
        .always(function() {
            alert( "complete" );
        });

解决方案

Cordova 5.0 blocks external http requests by default.

Try adding cordova-plugin-whitelist to your project.

这篇关于科尔多瓦/ PhoneGap的所有外部的Ajax请求,则返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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