massum

now i am able to view the data in the console but its not redirecting to that page. do i need to change. @tomo_pongrac and @Khudadad

Khudadad

@massum You returned the data to roombooking page and know you can display it.

return view ('partials.roombooking', compact('data'))->render() ;
{{ $data }}

Note: If you returned data as json simply get your element id and set it to the data returned.

$.ajax({
      url: '/roombooking',
      type: "get",
      data: {id:data},
       success: function(response){ 
      if(data == "success")
     // alert(response); 
$('#elementID').data(response.data); 
   },
error: function(response){
  alert('Error'+response);
 }
      });
massum

but here is the thing, i have written the ajax in the view name 'booking' and i want to display the fetched data from ajax in roombooking. currently the data is getting return to the booking view. not in roombooking view. @Khudadad

tomopongrac

You can write javaScript in external file and than you include that file in footer.

like this

<script type="text/javascript" src="/js/jquery.min.js"></script>
massum

what i mean is i want to take the value of one page and send it to another page. As i m new to laravel so i don't know how to go about it. So far i am able to get the data of the view to the controller. but from the controller how to return to another view is what i am not clear about. @Khudadad and @tomo_pongrac

massum

when i run the code as u sugested i get the link in the console "XHR finished loading: GET "http://localhost:8000/roombooking?id=2". but its not redirecting to that page. Kindly suggest me on how to achieve that i m really stuck in here and can't proceed further @Khudadad

Khudadad
rafaelmoura

@Khudadad

how I show my MODAL in ajax ? AJAXCONTROLLER:

public function returnProfile(Request $request) {
      if($request->ajax()){
        $id = $request->id;
        $profile = Profile::find($id);
        $data = view('administration.components.configurations.cards.card-profiles.models.view.view-profile', compact('profile'))->render();
        return response()->json( $data );
      }
    }

PROFILE.BLADE.PHP:

  <script>
    function Profile(id) {
      $.ajax({
        //url       : "/dashboard/perfil/"+id,
        url       : "/dashboard/perfil/",
        method    : 'GET',
        data      : { 'id' : id },
        //success   : 'success',
        //dataType  : 'JSON',
        success   : function(data){
          if(data){
            console.log(data);
            $('#viewProfile').modal('show');     <<<<<<<<<<<<<<<<<<?????
          }else{
            console.log('erro no modal');
          }
        }
      });
    }
  </script>

VIEW-PROFILE.BLADE.PHP:

<div class="modal fade" id="viewProfile" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="smallModalLabel">Visualização</h4>
            </div>
            <div class="modal-body">
                <strong>Perfil:</strong> {{ $profile->name }}
                <p>
                  <strong>Descrição:</strong> {{ $profile->label }}
                </p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success btn-link waves-effect">DELETAR</button>
                <button type="button" class="btn btn-danger btn-link waves-effect" data-dismiss="modal">CLOSE</button>
            </div>
        </div>
    </div>
</div>

Please sign in or create an account to participate in this conversation.