ajax 使用 phonegap 在 android 应用程序中无法调用

ajax call not working in android application using phonegap

我正在使用 phonegap 为 android 应用程序创建 apk 文件。下面是我的 index.html

的代码
<html>
<head><title>Test application</title>
    <script src="Scripts/jquery.js"></script>
    <script>
        $(document).ready(function(){
            $("#submitValue").on("click",function(){
                alert("");
                getServerResponse($("#userValue").val());
            });
        });

        function getServerResponse(userValue){
            var serverUrl="http://xxx.site.net/xxx/Hello/"+ userValue +"?format=json";
                $.ajax({
                    url:serverUrl,
                    type:"GET",
                    contentType:"application/json",
                    dataType:"jsonp",

                    success:function(data){
                        alert("Success");
                        $("#serverResponse").html(data.Result);
                    },

                    error:function(){
                        alert("error");
                    }
                });
            };
    </script>
</head>
<body>
    <div>
        <h3>Enter your name and click submit</h3>
    </div>

    <div>
        <input type="text" placeholder="Enter your Name" id="userValue"/>
        <input type="button" id="submitValue" value="Submit"/>
    </div>

    <div id="serverResponse"></div>
</body>

当我使用浏览器打开时,这非常有效,但是当打开应用程序并单击提交时,我收到单击警报,但之后没有任何反应。当我通过 android app

单击提交按钮时,既没有成功警报也没有错误警报

您需要在 AndroidManifest.xml 文件中授予 INTERNET 权限。 将下面的行包含到 AndroidManifest.xml

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