title: Display json response on ajax call via POST
body: <p>Im trying to display some data via JSON using ajax but for some reason when i submit the form im not getting any result, any suggestions?.. </p>
  
  <p>project_view.php</p>
  
  <pre><code>   &lt;form id="formProjectsRepSearch" action="controller.php" method="post" onsubmit="searchFormProjectsRep();
              return false"&gt;
              &lt;label&gt;Project Name &lt;/label&gt;
              &lt;input name="terbusqueda" id="term" type="text"&gt;
              &lt;button id="btnBuscar"&gt;Search&lt;/button&gt;
              &lt;input type="hidden" name="search" value="go"&gt;
    &lt;/form&gt;
    &lt;div id="ajaxProjectsRep"&gt;        
    &lt;/div&gt;
  </code></pre>
  
  <p>controller.php</p>
  
  <pre><code>  if (isset($_POST["search"]) &amp;&amp; $_POST["search"] == "go"){
  
        $name = $_POST['terbusqueda'];
  
        $project = new Project();
        $pro = $project-&gt;get_project($name);  
        $serv = $project-&gt;get_project_service_by_id($pro);
  
        echo json_encode($serv);       
  }
  require_once("../views/project_view.php");
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>function searchFormProjectsRep() {
  var $form = $('#formProjectsRepSearch');
  
  $.ajax({
      url: $form.attr('action'),
      data: $form.serialize(),
      type:'POST',
      success: function (resp) {
          var resp_object = $.parseJSON(resp); 
          $("#ajaxProjectsRep").html(resp_object.service);
      },
      dataType: "json"
  });
  }
  </code></pre>