我在jquery中有一个问题 - 帖子。当我在表单中输入电子邮件时,js-jquery会将电子邮件传递给sendResetPasswordMail1.php以检查电子邮件是否有效。
但现在,$ .post(“sendResetPasswordMail1.php”,mail:email},函数(resetPasswordMsg)无法在js中运行。
我找不到什么错。遇险。 请问你能帮帮我吗。 非常感谢。
PHP
public void secondarray(JsonParser jsonParser) {
String fieldName;
ameList = new ArrayList<AmeModel>();
AmeModel ameModel = null;
try {
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
ameModel = new AmeModel();
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
fieldName = jsonParser.getCurrentName();
if ("valueid".equals(fieldName)) {
jsonParser.nextToken();
ameModel.setId((jsonParser.getText()));
} else if ("valuename".equals(fieldName)) {
jsonParser.nextToken();
ameModel.setName((jsonParser.getText()));
} else {
jsonParser.skipChildren();
}
}
ameList.add(ameModel);
}
Spinner sp=new Spinner(MainActivity.this);
AmeAdapter adapter = new AmeAdapter(this, ameList);
sp.setAdapter(adapter);
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
Toast.makeText(MainActivity.this, ameList.get(i).getId(), Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
container.addView(sp);
//setContentView(linearlayout);
} catch (JsonParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
js - jquery
<!--reset Password Popup start-->
<div class="resetPasswordLayer" id="resetPassword" tabindex="-1">
<div class="resetPasswordLayerWall" id="resetPasswordLayerWall">
<button type="button" class="close resetPasswordCloseButton" aria-label="Close"><span aria-hidden="true">×</span></button>
<p><h3 class="layerTittle">Reset Password</h3></p>
<div class="row">
<!--<form class="form-horizontal" action="ResetPassword/sendResetPasswordMail.php" method="post" id="login-form">-->
<div class="form-horizontal form-group">
<div class="input-group">
<p><strong>User can retrieve the password through the mailbox</strong></p>
<!--<p><strong>Enter your registered e-mail, retrieve your password:</strong></p>-->
<p><input type="text" class="form-control" name="resetPasswordEmail" id="resetPasswordEmail" placeholder="Enter your registered e-mail, retrieve your password."><span id="chkresetPasswordMsg"></span></p>
</div>
</div>
<div class="form-group">
<div class="input-group"><!--<div class="col-md-11 col-md-offset-1">-->
<p><input type="button" class="btn btn-success" id="subSendResetPassword_btn" value="Reset"></p>
<!--<button type="submit" class="btn btn-success"id="subSendResetPassword_btn">Reset</button>-->
<span id="resetPasswordMsg"></span>
</div>
</div>
<!--</form>-->
</div>
</div>
</div>
<!--reset Password Popup End-->
php - sendResetPasswordMail1.php
$(function(){
$("#subSendResetPassword_btn").click(function(){
var email = $("#resetPasswordEmail").val();
var preg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/; //match Email
if(email=='' || !preg.test(email)){
$("#chkresetPasswordMsg").html("Please fill in the correct email!");
}else{
$("#subSendResetPassword_btn").attr("disabled","disabled").val('Submit......').css("cursor","default");
alert(email);
$.post("sendResetPasswordMail1.php",{mail:email},function(resetPasswordMsg){
if(resetPasswordMsg == ""){
alert("No Msg Return!");
}
if(resetPasswordMsg=="noRegister"){
$("#chkresetPasswordMsg").html("The mailbox is not registered yet!");
//$("#subSendResetPassword_btn").removeAttr("disabled").val('Submit').css("cursor","pointer");
}else{
$(".resetPasswordLayer").html("<h3>"+resetPasswordMsg+"</h3>");
}
});
}
});
})
答案 0 :(得分:0)
阻止默认点击事件
$("#subSendResetPassword_btn").click(function(e){
e.preventDefault()
});