-2

サイトで作業していて、ページのパスワード スクリプトをリセットする必要があります。そのために、古いパスワードと新しいパスワードを渡すために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);
    }
}); 
 });

値をページ名 ajaxServer に次のように渡す Java スクリプト:-

  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ページに情報を送信できないのですか...エラーを見つけるのを手伝ってください...事前に感謝します

4

1 に答える 1

0

エラーをキャッチできるように、成功だけでなくエラー プロパティも割り当てます。

于 2012-06-29T13:43:45.653 に答える