简体   繁体   English

登录代码无法在Internet Explorer中使用,但可以在Chrome和Firefox中使用

[英]Sign-in code not working in Internet Explorer but yes in Chrome and Firefox

I hope this isn't too much of a tedious question... I am working on this code that someone else wrote. 我希望这不是一个单调乏味的问题...我正在研究别人编写的这段代码。 The problem simply is that it works fine on Chrome and Firefox but not on Internet Explorer. 问题只是在于它在Chrome和Firefox上可以正常运行,但在Internet Explorer上却无法正常运行。 What happens is when clicking on the submit the page simply reloads and starts afresh. 当单击提交页面时,会发生什么情况,只是重新加载并重新开始。 I have no clue why? 我不知道为什么? Can anyone help? 有人可以帮忙吗?

Here is the HTML: It is essentially two fields that ask for phone number and pin code... 这是HTML:本质上是两个字段,要求输入电话号码和个人识别码...

<form name="form1" id="form1" onSubmit="get_client_data(); return false;" method="post" >
  <input type="hidden" name="random_1" id="random_1" value="<?=$session['random_1']?>" /> 
  <h2>ENTER THE NUMBER YOU’D LIKE TO REFILL</h2>
  <input placeholder="ENTER YOUR PHONE NUMBER:" name="phone_number" id="phone_number" type="text" class="form_input" onBlur="convert_phone(this.value,'phone_number');" />

  <h2>ENTER YOUR PIN</h2>
  <input placeholder="ENTER YOUR PIN CODE:" name="pin_id" id="pin_id" type="text" class="form_input" onBlur="check_validity(this.value, 'pin_id');" /><br>

  <input name="" type="submit" value="GO" class="right button go" id="step_1" />
  </form>

The onSubmit sends to the following javascript function: (this uses ajax to determine if the number and pin match and if they do - it will enable other parts of the HTML (not given here)) onSubmit发送到以下javascript函数:(这使用ajax来确定数字和引脚是否匹配以及它们是否匹配-它将启用HTML的其他部分(此处未给出))

function get_client_data(){

  var pin_id =  $('#pin_id').val(); 
  var phone_number = $('#phone_number').val();
  var random_1 =  $('#random_1').val();  

  $.ajax({
    type: "POST",
    url: "front_end_functions.php",
    data: "phone_number="+phone_number+"&plan="+plan+"&pin_id="+pin_id+"&random_1="+random_1+"&function=get_client_data",
    dataType: 'json',
    success: function(msg){  

    if(msg == 'error') {  
      alert('error'); 
      return false;             
   } else if(msg == 'error2') {
     alert('error'); 
      return false;
   } else {

    $('#div_1').addClass('deselect');
    $('#div_2').removeClass('deselect');   

    $('#phone_number').attr('disabled','disabled');
    $('#pin_id').attr('disabled','disabled');
    $('#step_1').attr('disabled','disabled');       

    $('#phone').removeAttr('disabled');
    $('#carrier').removeAttr('disabled');
    $('#plan').removeAttr('disabled');
    $('#step_2').removeAttr('disabled');   

    $('#phone').val(msg[1]);
    $('#carrier').val(msg[2]);
    $('#plan').val(msg[3]);  
   }
 }
 });
}

The function that Ajax sends to looks like this (as you can see I am using PDO - does that cause problems?): Ajax发送到的功能如下所示(如您所见,我正在使用PDO-会引起问题吗?):

if($_REQUEST['function'] == 'get_client_data')  {

$random_1 = $_REQUEST['random_1'];
$ip = getenv('HTTP_CLIENT_IP')?:
getenv('HTTP_X_FORWARDED_FOR')?:
getenv('HTTP_X_FORWARDED')?:
getenv('HTTP_FORWARDED_FOR')?:
getenv('HTTP_FORWARDED')?:
getenv('REMOTE_ADDR');

$query = $db->prepare("SELECT * FROM sessions WHERE id = ?");
$query->execute(array($ip));
$session = $query->fetch();

if($session['random_1'] == $random_1) {

  $phone_number = $_REQUEST['phone_number'];
  $pin_id = $_REQUEST['pin_id'];

  $sql = "SELECT c.cid, cp.phone, cr.carrier_name, p.plan_name ,cp.carrier as cr_id,cp.plan as p_id
          FROM clients c, client_phones cp , carriers cr, plans p
          WHERE cp.phone = ? 
          AND cp.client_id = ?
          AND cp.deleted = 0
          AND c.cid = cp.client_id 
          AND c.status = 'a'
          AND cr.carrier_id = cp.carrier
          AND p.plan_id = cp.plan";

  $query = $db->prepare($sql);
  $query->execute(array($phone_number, $pin_id));
  $result = $query->fetch();
  if(!empty($result)){
        $_SESSION['client'] = $result;
        echo json_encode($result);
  }else{
    echo json_encode('error'); 
    }
}else{
  echo json_encode('error2');
}     
}   

Thanks! 谢谢!

Yep - worked it out, Using the debugger on IE (sorry for not doing that earlier) it says that 'plan' in the data part of the ajax code is undefined. 是的-解决了这一问题,在IE上使用调试器(抱歉,您之前没有这样做)表示ajax代码的数据部分中的“计划”未定义。 So that caused the error. 这样就导致了错误。 Interesting that Chrome and Firefox don't have that problem... 有趣的是Chrome和Firefox没有这个问题...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于网站的基本Google登录代码无法在Internet Explorer 11中使用 - Basic Google Sign-In for Websites code not working in Internet Explorer 11 为什么这在fireFox中有效,但在Chrome或Internet Explorer 9中却无效? - Why is this working in fireFox but not in Chrome or Internet Explorer 9? Cookie代码可在FireFox和Explorer中工作,但不能在Chrome中工作 - Cookie code working in FireFox and Explorer but not Chrome selectedOptions.length在Internet Explorer中不起作用,但在chrome和firefox中可以正常工作吗? - selectedOptions.length not working in Internet explorer but works properly in chrome and firefox? Flot图在Firefox或Internet Explorer中无效,仅适用于Chrome - Flot graph not working in Firefox or Internet Explorer, only Chrome 包含外部HTML的JavaScript在Chrome中运行,但在Internet Explorer和Firefox中不起作用 - JavaScript to include external HTML is working in Chrome but not in Internet Explorer and Firefox 在Chrome和Firefox中可以使用Canvas元素+ Javascript,而不能在Internet Explorer中使用 - Canvas element + Javascript working in Chrome and Firefox, not in Internet Explorer 为什么我的代码在Firefox中可以,但在Chrome和Internet Explorer 8中却不能? - Why is my code OK in Firefox, but not in Chrome and Internet Explorer 8? 幻灯片只能在Firefox中使用,而不能在Internet Explorer中使用 - slideshow working in firefox but not internet explorer Jquery在Firefox中工作但不在Internet Explorer中工作 - Jquery working in Firefox but not Internet Explorer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM