title: Laravel passing data from ajax to modal view which is on a separate file causing modal to not render
body: <p>Here is my blade view, it lists debiturs and all their properties like id, name, address. This also have a modal view button that pops a modal that is supposed to query the debitur by id then show the details of it <code>data-target="#viewModal" onclick='showDetail({{$var-&gt;id}});</code></p>
  
  <p>(ajax_table.blade):</p>
  
  <pre><code>&lt;?php
  if(!empty($data)){$isi = json_decode($data);}
  if(!empty($modaldata)){$isimodal = json_decode($modaldata);}
   ?&gt;
  
  @if(!empty($isi-&gt;data))
      @foreach($isi-&gt;data as $var)
      @include('userdebitur.ajax_modal_view')
      &lt;tr&gt;
          &lt;td&gt;{{ $var-&gt;id }}&lt;/td&gt;
          &lt;td&gt;{{ $var-&gt;name }}&lt;/td&gt;
          &lt;td&gt;{{ $var-&gt;address }}&lt;/td&gt;
          @endif
          &lt;td&gt;
              &lt;div class="btn-group"&gt;
                  &lt;button title="Detail Info" type="button" class="btn btn-default btn-flat" data-toggle="modal" data-target="#viewModal" onclick='showDetail({{$var-&gt;id}});'&gt;&lt;i class="fa fa-eye"&gt;&lt;/i&gt;&lt;/button&gt;
              &lt;/div&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      @endforeach
  @else
      &lt;tr&gt;&lt;td align="center" colspan="5"&gt;Not found.&lt;/td&gt;&lt;/tr&gt;
  @endif
  </code></pre>
  
  <p>Here is my modal file that is called from above (ajax_modal_view.blade):</p>
  
  <pre><code>    &lt;div class="modal fade" id="viewModal"&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content mdl-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                      &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
                      &lt;h4 class="modal-title"&gt;Default Modal&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      &lt;p&gt;test @if(isset($isimodal)){var_dump($isimodal)} @endif&lt;/p&gt; //I'm trying to output this
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;button type="button" class="btn btn-default pull-left" data-dismiss="modal"&gt;Close&lt;/button&gt;
                      &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>The modal view button also called showDetail() passing debitur id as variable then returning data from the controller by calling a function inside ajax.blade:</p>
  
  <pre><code>function showDetail(id)
  {
      $.ajax({
          type:"GET",
          url: "{{ url('ajax/userdebitur/') }}"+"/"+id,
          dataType: "json",
          cache: false,
          success: function(modaldata){        
              $("#viewModal").html(modaldata.view); //this is likely the problem
          },
          error: function (modaldata) {
              // 
          }
      });
  }
  </code></pre>
  
  <p>And this is my controller:</p>
  
  <pre><code>public function getdebitur($id)
  {
      $content = Debitur::find($id);
      $modaldata['content'] = $content;
      $modaldata['view'] = view('userdebitur.ajax_modal_view')-&gt;with('modaldata', json_encode($content))-&gt;render();
  
      echo json_encode($modaldata);
  }
  </code></pre>
  
  <p>When using console in web browser, I have successfully retrieved the selected debitur data showing all the objects, however I can't seem to pass anything to the modal.
  I have tried passing the data to the ajax_table.blade itself, moving the modal inside ajax_table.blade, passing data without view from the controller, moving json_decode($modaldata) inside the modal itself, all to no avail.</p>
  
  <p>If in the ajax.blade I use <code>$("#viewModal").html(modaldata.view);</code> modal is showing for one second then disappear, but if I use <code>$("#viewModal").modal(modaldata.view);</code> or <code>$("#viewModal").modal(modaldata);</code> it's showing with no $isimodal value.</p>
  
  <p>What I want to do: getting the value passed from the controller and var_dump it in the modal.</p>