我正在网站上工作,我必须在页面上重置密码脚本。为此,我使用ajax传递旧密码和新密码,并希望在同一页面上获得结果
我的重置页面代码是: -
<label>Enter current Password:</label><input id="cur_password" type="password" /><br/>
<label>Enter New Password:</label><input id="new_password" type="password" /><br/>
<label>Confirm New Password:</label><input id="confirm_password" type="password" /><br/>
<a id="Reset_pass" class="submitButtons" value="Submit">Submit</a>
我处理此请求的java脚本页面是: -
$('#Reset_pass').click(function(){
var cur_password = $('#cur_password').val();
var new_password = $('#new_password').val();
var confirm_password = $('#confirm_password').val();
$('#current_password').parent().append("<img src=\"includes/ajaxLoader.gif\"");
$.ajax({
url: 'ajaxServer.php?request=Reset_password',
type: 'POST',
data: {'cur_password': cur_password,'new_password': new_password,'confirm_password': confirm_password},
dataType: "html",
success: function(result){
$('#current_password').parent().children('img').remove();
$('#current_password').parent().children('span.updateResults').remove();
$('#current_password').parent().append(result);
}
});
});
和java脚本将值传递给页面名称ajaxServer: -
if($request == "Reset_password")
{
$db_name = "user_mgmt";
include "connections/Con.php";//for database connection
$temp=$_SESSION['username'];
$result = mysql_query("select Password from register where Unique_id=$temp");
$row = mysql_fetch_array($result);
$status=strcmp('$_POST[cur_password]','$row[0]');
$confirm_pass=strcmp('$_POST[new_password]','$_POST[confirm_password]');
if(($status==0)&&($confirm_pass==0))
{
$query = mysql_query("UPDATE register SET Password='$_POST[new_password]' where Unique_id='$temp'");
}
?>
<span class="updateResults">
<?php
if($query){
echo "Your Password is reset";
}
else{
echo "Unable ";
}
?>
</span>
}
但是在java脚本代码中有错误..这就是为什么它无法向ajaxServer页面发送信息...请帮我找到错误...提前感谢
答案 0 :(得分:0)
分配错误属性而不仅仅是成功,这样你就可以捕获错误。