密码字段没有使用ajax到达php

所以我在调试问题时遇到问题。 可能是Jquery或PHP问题。 我做了相当多的警报测试,我相信问题在于ajax的if语句,例如,如果在发布时没有禁用该字段,我将发布传递。 因为当做回声$ _POST [‘pass’]和警报(数据)时,我什么也得不到。 所以我相信php工作正常请告诉我问题在哪里,如果你也知道这种情况的补救措施。 多谢你们。

阿贾克斯

$(document).on('submit', '#editaccsount', function(event) { event.preventDefault(); myData = { contactname: $('input[name=contactname]').val(), business: $('input[name=business]').val(), email: $('input[name=email]').val(), code: $('input[name=code]').val(), phone: $('input[name=phone]').val(), priceband: $('input[name=priceband]').val(), address: $('input[name=address]').val(), active: $('input[name=active]').val(), mon: $('input[name=mon]').val(), tue: $('input[name=tue]').val(), wed: $('input[name=wed]').val(), thu: $('input[name=thu]').val(), fri: $('input[name=fri]').val(), sat: $('input[name=sat]').val(), sund: $('input[name=sund]').val(), adminname: $('input[name=adminname]').val(), accountid: $('input[name=accountid]').val(), isadmin: $('input[name=isadmin]').val(), }; var isDisabled = $('input[name=pass]').prop('disabled'); if (isDisabled == false) { myData.pass = $('input[name=pass]').val(); } $.ajax({ url: 'php/editaccount.php', type: "POST", data: myData, success: function(data) { if ($('input[name=isadmin]').val() == 1) { $('input[name=accountsearch]').val($('input[name=email]').val()); $('input[name=accountsearch]').submit(); } else { $('input[name=accountsearch]').val($('input[name=business]').val()); $('input[name=accountsearch]').submit(); } alert(data); } }); }); 

这是我的PHP,它根据条件进行所有更新:

 <?php require '../../core/init.php'; $auth = new Auth(); $accid = $_POST['accountid']; echo $accid, '
'; echo 'Password is: ', $_POST['pass'], '
'; echo 'Is Admin: ', $_POST['isadmin']; if (!empty($_POST['pass'])) { echo 'Pass Detected'; echo 'Password: ', $_POST['pass'], "
"; $salt = $auth->randomString(); $newpass = $salt . $_POST['pass']; $newpass = $auth->hashData($newpass); if ($_POST['isadmin'] == 0) { $customer = DBPDO::getInstance()->update('customer', $accid, array( 'businessName' => $_POST['business'], 'contactName' => $_POST['contactname'], 'email' => $_POST['email'], 'code' => $_POST['code'], 'phone' => $_POST['phone'], 'priceBand' => $_POST['priceband'], 'deliveryAddress' => $_POST['address'], 'is_active' => $_POST['active'], 'mon' => $_POST['mon'], 'tue' => $_POST['tue'], 'wed' => $_POST['wed'], 'thu' => $_POST['thu'], 'fri' => $_POST['fri'], 'sat' => $_POST['sat'], 'sun' => $_POST['sund'], 'password' => $newpass, 'user_salt' => $salt )); } elseif ($_POST['isadmin'] == 1) { $admin = DBPDO::getInstance()->update('admin', $accid, array( 'adminName' => $_POST['adminname'], 'email' => $_POST['email'], 'phone' => $_POST['phone'], 'password' => $newpass, 'user_salt' => $salt )); } } elseif (empty($_POST['pass'])) { echo 'Pass NOT detected'; if ($_POST['isadmin'] == 0) { $customer = DBPDO::getInstance()->update('customer', $accid, array( 'businessName' => $_POST['business'], 'contactName' => $_POST['contactname'], 'email' => $_POST['email'], 'code' => $_POST['code'], 'phone' => $_POST['phone'], 'priceBand' => $_POST['priceband'], 'deliveryAddress' => $_POST['address'], 'mon' => $_POST['mon'], 'tue' => $_POST['tue'], 'wed' => $_POST['wed'], 'thu' => $_POST['thu'], 'fri' => $_POST['fri'], 'sat' => $_POST['sat'], 'sun' => $_POST['sund'] )); } elseif ($_POST['isadmin'] == 1) { $admin = DBPDO::getInstance()->update('admin', $accid, array( 'adminName' => $_POST['adminname'], 'email' => $_POST['email'], 'phone' => $_POST['phone'] )); } }

什么输出为HTML:

 get('customer', array( array('businessName', '=', "'$searchquery'" ) )); foreach ($customer->results() as $row) { $data['result_1'] .= ' 
id.'">

General Details

contactName.'">
businessName.'">
email.'">
code.'">
phone.'">
priceBand.'">
deliveryAddress.'">
is_active.'">
password.'">
Warning: If you do NOT want to edit Password please click Cancel!



Standing Order Details

mon.'">
tue.'">
wed.'">
thu.'">
fri.'">
sat.'">
sun.'">
id.'">
'; } } elseif ($_POST['accounttype'] == 'Admins') { $customer = DBPDO::getInstance()->get('admin', array( array('email', '=', "'$searchquery'" ) )); foreach ($customer->results() as $row) { $data['result_1'] .= '
id.'">

General Details

adminName.'">
email.'">
phone.'">
password.'">
id.'">
'; } } echo json_encode($data); exit; ?>

您正在检查残疾人的财产:

 var isDisabled = $('input[name=pass]').prop('disabled'); 

如果我记得这将返回一个空字符串或disabled作为一种使用方式,这将是:

 $('input[name=pass]').prop('disabled', 'disabled'); 

如果您正在寻找true/false可以尝试:

 var isDisabled = $('input[name=pass]').is(':disabled'); 

它会返回true或false。