【问题标题】:why the parameter read by true?为什么读取的参数为true?
【发布时间】:2020-06-22 16:40:33
【问题描述】:

我试图调用变量 $hetest 但它总是返回 true 但是我在调​​用函数时添加了 false 作为参数

 //function which i call in javascript file
         create_new_user_send_sms(user_Mobile_Number,false)
                              .fail(error => console.error(error))
                              .done(response => {})
   //the ajax call of the function i created 
      function create_new_user_send_sms(mobile_number,hestatus){
            return jQuery.ajax({
              type : "POST",     
              url: ajax_object.ajax_url,
              data: {    
                action : 'create_user_send_sms',     
                mobile_number : mobile_number,
                auto_Login_status : "true",
                he : hestatus,
              },

              success: function (data) {  
              },

              error : function(error){
                  console.log("error:" + error);
              }
           });
        }

//the code in the php function create_user_send_sms
 $mobile_number = $_POST['mobile_number'];
  $auto_Login_status = $_POST['auto_Login_status'];
  $hetest = $_POST['he']; 
  $password = wp_generate_password( 4, false, false );

【问题讨论】:

标签: javascript php jquery


【解决方案1】:

尝试使用 filter_validation 函数来处理 boolean post vars:

$hetest = filter_var ($_POST['he'], FILTER_VALIDATE_BOOLEAN);

【讨论】:

    猜你喜欢
    • 2022-01-02
    • 2020-10-02
    • 2013-02-02
    • 1970-01-01
    • 2017-11-01
    • 2016-09-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多