簡體   English   中英

Codeigniter JQuery Ajax發布空值

[英]Codeigniter JQuery ajax post null value

我正在使用jquery ajax將數據發送到控制器,但它返回null。

我只想使用ajax將單個輸入文本發送到控制器。

 <script> $(document).ready(function() { $("#sendOtp").click(function(e){ console.log("working"); e.preventDefault(); //var mobileno = $("#mobileno").val(); $.ajax({ type:"POST", url:"<?php echo base_url()?>"+"index.php/welcome/generateOtp", data: {mobileno: $("#mobileno").val()}, dataType: "json", cache:false, success:function(response){ console.log(response); }, error: function ($data) { console.log(data); } }); }); }); </script> 

public function generateOtp(){

    $mobile = $this->input->post('mobileno');


    echo $mobile;

}

這是我必須發送數據的HTML

  <div class="form-group">
                <div class="col-sm-12">
                  <input type="text" class="form-control" name="mobileNo" id="mobileNo" placeholder="mobile">
        <br>
        <button class="btn" id="sendOtp">Send OTP</button>
                </div>
              </div>

區分大小寫,mobileNo和mobileno不同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM