title: Laravel Submit Form Without Page Refresh Using Ajax
body: <p>I want to post the phone number in my modal popup form.but don't want to disappear the popup after submitting the form clicking on &quot;continue&quot; button. Here is my blade.php code.</p>
     
                  
                 
  <pre><code>            &lt;div id=&quot;modal-wrapper&quot; class=&quot;modal&quot;&gt;
    
                &lt;form class=&quot;modal-content animate&quot; id=&quot;addform&quot;&gt;
                 
                                 
                      &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;phone_number&quot; placeholder=&quot;01**********&quot;&gt;
                    &lt;/div&gt; 
                    &lt;/div&gt;
                    
                  &lt;div style=&quot;text-align: center; margin-top: 10px;padding-left:18px;&quot;&gt;
                    &lt;button type=&quot;submit&quot;  style=&quot;background-color: #a5abb0;&quot; class=&quot;mobile-login__button&quot;&gt;CONTINUE
                  &lt;/button&gt;
                &lt;/div&gt;
  </code></pre>
  <p>here is my script part for ajax part of the code.</p>
  <pre><code> &lt;script&gt;
                  
                    $(&quot;#addform&quot;).on('submit',function(e){
                      e.preventDefault();
                
                      $.ajax({
                        type:&quot;post&quot;
                        url: &quot;/client-mobile-login&quot;
                        data: $(&quot;addform&quot;).serialize(),
                        success:function(response){
                          
                        },
                        error:function(error){
                          console.log(error)
                          alert(&quot;not send&quot;);
                        }
                
                        )};
                      });
                    
                  });
                
                  &lt;/script&gt;
  </code></pre>
  <p>and here is my controller function</p>
  <pre><code>     public function client_mobile_login(Request $request)
        {
         $client_phone1='88'.$request-&gt;input('phone_number');
      
      $result=DB::table('client')
              -&gt;where('client_phone1',$client_phone1)
              -&gt;first();
             {{ here is my otp sending code.... }}
  
              if($result)
              {       
                     $request-&gt;session()-&gt;put('client_title', $result-&gt;client_title);
                     
  
                 // print_r($client_phone1);
                 } 
  </code></pre>