mercredi 28 mars 2018

How to show message in Popup without reloading the page in Laravel? I am sending data using CURL

This is dashboard.blade.php My View.

<form class="form-horizontal" role="form" method="post" action="" enctype="multipart/form-data">
   <input type="hidden" name="_token" value="">  
   <div class="row">
    <div class="col-md-6">
            <fieldset style="height: auto;">
                    <legend>Complaint Details</legend>
                    <div class="form-group row">
                            <label class="col-md-6 control-label" for="pnr">PNR/Unreserved Tickets No <span class="errors">*</span>: </label>
                            <div class="col-md-6">          
                                    <input type="text" class="form-control" maxlength="10" name="pnr" id="pnr" placeholder="PNR/Unreserved Tickets No." required>
                            </div>
                    </div>
                 </div>
              </div>
           </form>

This is my DashboardController.php

  public function formSubmit(Request $request){ 
  $data1 = [
        'name'=> $passName,
  ];
   $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => "xyz.com",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS =>$data1,
        CURLOPT_HTTPHEADER => array(
            "Content-Type: multipart/form-data",
          ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);
    if ($err) {
        return redirect()->back()->with('message','Error on submitting form.'); 
    } else {  
            return redirect()->back()->with('message','Thank You for Submitting Complaint');
        }

It is working fine. I am sending the data through CURL in Laravel. I just want to not refresh the page after submitting the Form. I just want to show the Successful message or error message in a popup. When I am submitting the form, It reloads the page. I just don't want to reload the page.

Thanks In Advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire