title: Ajax is not working in codeigniter 4 when call the controller
body: <p>I just want to make sure this ajax is working to call my controller. But when i click the button nothing happened. Thank you</p>
  <p>My view :</p>
  <pre><code>&lt;input type=&quot;text&quot; id=&quot;phonenumber&quot; name=&quot;phonenumber&quot; class=&quot;form-control&quot; placeholder=&quot;Phone number&quot;&gt;
  &lt;button type=&quot;button&quot; id=&quot;sendotp&quot; name=&quot;sendotp&quot; class=&quot;btn btn-primary btn-block&quot;&gt;Sign Up&lt;/button&gt;
  </code></pre>
  <p>My AJAX :</p>
  <pre><code>$(document).ready(function() {
    $('#sendotp').click(function(e) {
      e.preventDefault();
  
            var phonenumber = $(&quot;input[name='phonenumber']&quot;).val();
  
            $.ajax({
                  url: '&lt;?php echo base_url();?&gt;/register',
                  type:'post',
                dataType:'json',
                  data: {
                    phonenumber:phonenumber
                  },
                  success: function(data) {
                  }
              });
    });   
  });
  </code></pre>
  <p>My Controller :</p>
  <pre><code>public function register()
      {   
          if($this-&gt;request-&gt;getMethod() == 'post'){
  
              $phonenumber = $this-&gt;request-&gt;getPost('phonenumber');
              echo $phonenumber;
          }
          return view('register/register');
      }
  </code></pre>
  <p>My Routes :</p>
  <pre><code>$routes-&gt;match(['get', 'post'],'/register', 'Home::register');
  </code></pre>