我正在开发一个带有PhoneGap的Andorid应用程序,我正在尝试进行身份验证。我有一个HTML文件的简单形式,在活动中点击一个JS文件前人的精力启动激活了autentication远程服务器上的PHP文件中的阿贾克斯,这里是JS:使用Ajax的PhoneGap身份验证
$("#login").click(function(){
var username=$("#username").val();
var password=$("#password").val();
var dataString="username="+username+"&password="+password;
$.ajax({
type: "POST",
url: "http://@@##.altervista.org/test.php",
data: dataString,
beforeSend: function(){ $("#login").html('Connecting...');},
success: function(responce){
if(responce=='success')
{
localStorage.login="true";
localStorage.username=username;
window.location.href = "index.html";
}
else
{
alert("Login error");
$("#login").html('Login');
}
}
});
return false;});
的PHP文件是一个简单的回声“成功”。 当我运行它时,它仍然停留在函数beforeSend
中。
security-policy
:
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
3210:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Hello World</name>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />
****some plugin, icon and splash that i need***
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<engine name="android" spec="~5.1.1" />
</widget>
请同时发布您的config.xml和index.html的'
'部分,特别是内容安全策略元标记。这些的正确配置可能是一个因素。 –@MarcoCuccagna编辑您的文章与此信息 – piterio