【发布时间】:2016-06-17 05:52:14
【问题描述】:
我正在使用 phonegap 开发一个移动应用程序,我有一个 form 来注册新用户。在浏览器(chrome 和 firefox)中,表单在正确时可以正常工作
已填充,如果有问题则显示错误。我在函数的开头有一个alert('work!'); 来检查是否被调用,在浏览器中出现警报但在应用程序中没有。可以是什么?
Ps:我的网站上已经有<access origin="">,表单的php文件在哪里。
编辑:
形式:
<form id="cadastro" method="post">
<input type="text" style="height:30px;margin-bottom:10px;margin-top:10px;font-size:18px" name="nome" id="textinput-2" placeholder="Nome" required>
<input type="text" style="height:30px;margin-bottom:10px;font-size:18px" name="email" id="textinput-1" placeholder="Email" required>
<div id="email_erro"></div>
<input type="password" style="height:30px;margin-bottom:10px;font-size:18px" name="senha" id="password" placeholder="Senha" autocomplete="off" required>
<input type="password" style="height:30px;margin-bottom:10px;font-size:18px" name="repetir_senha" id="re_password" placeholder="Repetir senha" autocomplete="off">
<div id="senha_erro"></div>
<fieldset data-role="controlgroup" style="margin-left:5%" data-type="horizontal" data-mini="true">
<input type="radio" name="sexo" id="radio-choice-c" value="m" checked="checked" required>
<label for="radio-choice-c">Masculino</label>
<input type="radio" name="sexo" id="radio-choice-d" value="f" required>
<label for="radio-choice-d">Feminino</label>
</fieldset>
<div style="margin-left:3.5%;margin-right:4%;">
<input type="checkbox" name="newsletter" id="checkbox-mini-0" value="1" data-mini="true">
<label for="checkbox-mini-0">Quero receber as ofertas e novidades</label>
<input type="checkbox" name="termo" id="checkbox-mini-1" data-mini="true" required>
<label for="checkbox-mini-1">Aceito os Termos de Uso e Política de privacidade</label>
<button type="submit" class="ui-btn ui-shadow ui-corner-all" id="termo" style="float:none;margin-left:2%">Criar conta</button>
</div>
</form>
功能:
<script>
alert('entrou no script');
$('#cadastro').submit(function(){
var valor = $('#cadastro').serialize();
$.ajax({
type: 'POST',
url: 'cadastro',
dataType: "json",
data: valor
}).success(function(response){
alert('retornou função');
if (response.sucesso) {
window.localStorage["email"] = response.dados.email;
window.localStorage["nome"] = response.dados.nome;
window.localStorage["sexo"] = response.dados.sexo;
window.localStorage["id"] = response.dados.id;
//window.localStorage["UID"] = data.uid;
window.location = "logado.html";
} else {
alert("Verifique seus dados");
$('#email_erro').html(response.erro_email);
$('#senha_erro').html(response.erro_repetir_senha);
//window.location("main.html");
}
});
return false;
});
</script>
【问题讨论】:
-
我们可以看看相关的代码吗?
-
当然,我编辑了我的帖子。
-
您是否包含了cordova javascript 文件? -
-
是的,包括在内