Javascript 使用Ajax/JQuery/PhoneGab重定向
我第一次使用PhoneGab,但有点不对劲 当我收到“数据”时,我会使用window.location.href方法(json在Ajax请求(跨域)之前从PHP收到响应) 但是当我在我的手机(Android)上测试这个想法时,重定向不起作用 附:在网络浏览器上一切正常 有人看到问题了吗 这是我的密码:Javascript 使用Ajax/JQuery/PhoneGab重定向,javascript,php,jquery,ajax,phonegap-build,Javascript,Php,Jquery,Ajax,Phonegap Build,我第一次使用PhoneGab,但有点不对劲 当我收到“数据”时,我会使用window.location.href方法(json在Ajax请求(跨域)之前从PHP收到响应) 但是当我在我的手机(Android)上测试这个想法时,重定向不起作用 附:在网络浏览器上一切正常 有人看到问题了吗 这是我的密码: <html> <head> <title>Ajax Cross-Origin</title> <script type="te
<html> <head>
<title>Ajax Cross-Origin</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.js"></script>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" href="css/bootstrap/css/bootstrap.min.css" /> </head>
<body>
<div id="body-inside" data-role="page">
<div class="logo-inside">
<a href="index.html" class="connexionForm">
<span id="arrowLeft" class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>
</a>
</div>
<div class="titre"><h1 id="inscTitle">Inscription</h1></div>
<form class="FormInscription" method="POST">
<label>Nom</label>
<input type="text" name="nom" id="nom" placeholder="nom"/>
<label>Prénom</label>
<input type="text" name="prenom" id="prenom" placeholder="prénom"/>
<label>Email</label>
<input type="email" name="email" id="email" placeholder="xyz@email.com"/>
<label>Mot de passe</label>
<input type="password" name="password1" id="mdp1" placeholder="xxx123"/>
<label>Confirmer votre mot de passe :</label>
<input type="password" name="password2" id="mdp2" placeholder="xxx123"/>
<button id="saveLogin" >
Suivant
</button>
</form>
</div>
<script type="text/javascript">
function redirect(){
window.location.href = "inscription_suite.html";
} $(function() {
$( '#saveLogin' ).click(function(){
var nom = $("#nom").val();
var prenom = $("#prenom").val();
var email = $("#email").val();
var mdp1 = $("#mdp1").val();
var mdp2 = $("#mdp2").val();
$.post( "http://webawards.io/data.php",{
firstname : nom,
lastname : prenom,
mail : email,
pass1 : mdp1,
pass2 : mdp2
},function( data ) {
if(data!=="false"){
sessionStorage.setItem("id", data);
redirect();
} else if(data=="false"){
alert("Une erreur semble s'être produite, veuillez réessayer");
}
});
});
}); </script>
</body> </html>
Ajax交叉源
铭文
笔名
名词
电子邮件
路况
确认人未通过:
苏万特
函数重定向(){
window.location.href=“edintition\u suite.html”;
}$(函数(){
$('#saveLogin')。单击(函数(){
var nom=$(“#nom”).val();
var prenom=$(“#prenom”).val();
var email=$(“#email”).val();
var mdp1=$(“#mdp1”).val();
var mdp2=$(“#mdp2”).val();
$.post(”http://webawards.io/data.php",{
名字:nom,
姓氏:prenom,
邮件:电邮,,
pass1:mdp1,
pass2:mdp2
},函数(数据){
如果(数据!=“假”){
setItem(“id”,数据);
重定向();
}否则如果(数据==“假”){
警惕(“我们的产品是错误的,我们的产品是错误的”);
}
});
});
});
更新后的cordova版本不允许您通过javascript重定向。为了使javascript重定向正常工作,您需要按照说明进行操作
在config.xml中添加“”
<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />
<content src="index.html" />
或者干脆
<plugin name="cordova-plugin-whitelist" spec="1.1.0" />
尝试将以下内容放入config.xml中
<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />
<content src="index.html" />
是源目录中HTML文件的路径
<access origin="*" />
将允许您使用JS重定向到任何外部页面。如果你想将你的应用程序限制在一个域内,那么就这样使用它
<access origin="http://yourdomain.com" />
最后,提出以下意图
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
您知道这两个都是网站包装吗?此外,最佳实践是将网页放在设备上。Jesse是对的。这就是为什么谷歌和苹果增加了“添加到主屏幕”选项,用户可以将你的网页添加到他们的主屏幕上。