title: Laravel 4 ajax with partial views
body: <p>im new with laravel 4 started a few days ago. My problem is simple, i have a combobox which the client or the user changes and renders a "partial" view.</p>
  
  <p><img src="https://i.stack.imgur.com/WkAXj.png" alt="enter image description here"></p>
  
  <p>this is my first view. OnChange:</p>
  
  <p><img src="https://i.stack.imgur.com/uZq7g.png" alt="enter image description here"></p>
  
  <p>will render that simple message through javascript</p>
  
  <p>my problem is if i place the value "by hand" it will only show the partial view:</p>
  
  <p><img src="https://i.stack.imgur.com/OwmhH.png" alt="enter image description here"></p>
  
  <p>this is my function in the controller</p>
  
  <pre><code>    public function getTeste1() {
      $id = Input::get('value');
      if($id=="")
      {
          $this-&gt;layout-&gt;content = View::make('home.user');
      }
      else
      {
          $this-&gt;layout-&gt;content = View::make('home.user2')-&gt;with('ides',$id);
      }
  }
  </code></pre>
  
  <p>this my javascript function:</p>
  
  <pre><code>function showCustomer(str)
  {
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
  var url="";
  url="?value="+str;
  //url=url+"&amp;sid="+Math.random();
  // alert(url);
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(true);
  }
  </code></pre>
  
  <p>this is my view:</p>
  
  <pre><code>&lt;h1&gt;Home&lt;/h1&gt;
  
  &lt;p&gt;Welcome to your Home. You rock!&lt;/p&gt;
  
  &lt;form&gt;
  &lt;select name="users" onchange="showCustomer(this.value)"&gt;
  &lt;option value="0"&gt;Select a person:&lt;/option&gt;
  &lt;option value="1"&gt;Peter Griffin&lt;/option&gt;
  &lt;option value="2"&gt;Lois Griffin&lt;/option&gt;
  &lt;option value="3"&gt;Glenn Quagmire&lt;/option&gt;
  &lt;option value="4"&gt;Joseph Swanson&lt;/option&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  &lt;div id="txtHint"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>this is my partial view:</p>
  
  <pre><code>@if($ides!=0)
  &lt;div id="txtHint"&gt; &lt;b&gt;Person info will be listed here -&gt; {{ $ides }} &lt;/b&gt;&lt;/div&gt;
  @endif
  </code></pre>
  
  <p>I know why i have this problem, i don't know how to avoid it if you guys know it will be very helpful, or other away to do it.</p>
  
  <p>Thank you,</p>
  
  <p>Gonçalo Moura</p>
  
  <p>EDITED:
  if i use your solution it will show like this:
  <img src="https://i.stack.imgur.com/S6DZo.png" alt="enter image description here"></p>
  
  <p>StateChanged function:</p>
  
  <pre><code>function stateChanged()
  {
     if (xmlHttp.readyState==4)
     {
        document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
  
        // alert(document.getElementById("txtHint").innerHTML);
  
     }
  }
  </code></pre>
  
  <p>jquery function:</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function() {
  $("#users").change(function() {
    $.get('http://localhost/LoginProject/public/home/teste1?value=' + $(this).val(),         function(data) {
      $("#txtHint").html(data);
    });
  });
  });
  &lt;/script&gt;
  </code></pre>