Ajax调用结果无法正常工作

时间:2018-06-11 10:41:46

标签: javascript php jquery ajax

我有这个功能,在onkeyup上它验证手机号码是否已经存在于数据库中,现在问题是即使响应是" true"它将始终显示为false

PHP

elseif ($action == 'check_mobile_phone')
{

    $mobile = trim($_GET['mobile']);
    $mobile = json_str_iconv($mobile);

    if (mobile_register($mobile))
    {
        echo 'false';
    }
    else
    {
        echo 'true';
    }
}

Ajax Call

function checkMobilePhone(mobile)
{

  if (mobile == '')
  {
   error.find('#mobile_notice_text').html('Mobile number cant be empty.');
   submit_disabled = true;
  }
  else if (!Utils.isMobile(mobile))
  {
    error.find('#mobile_notice_text').html('Please enter mobile number in local format.');
  }

  if( submit_disabled )
  {
    document.forms['formUser'].elements['Submit'].disabled = 'disabled';
    return false;
  }
  Ajax.call( 'user.php?act=check_mobile_phone', 'mobile=' + mobile, check_mobile_callback , 'GET', 'TEXT', true, true );
}

响应

function check_mobile_callback(result)
{
  var logform = $('form[name="formUser"]');
  var error = logform.find('#mobile_notice');

  if ( result === "true" )
  {
    document.forms['formUser'].elements['Submit'].disabled = '';
  }
  else
  {
    error.find('#mobile_notice_text').html('Phone number already exists.');
    document.forms['formUser'].elements['Submit'].disabled = 'disabled';
  }
}

1 个答案:

答案 0 :(得分:0)

crypto-config/peerOrganizations/org2.umarkcloud.com/users/User11@org2.umarkcloud.com/msp/admincerts"