我正在使用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应用程序点击提交按钮
时,既没有成功警报也没有错误警报答案 0 :(得分:1)
您需要在AndroidManifest.xml文件中授予INTERNET权限。 将下面的行包含在AndroidManifest.xml
中<uses-permission android:name="android.permission.INTERNET"/>