title: How to receive and handle response from the Php Script while using it with jQuery Ajax method
body: <p>How can I receive and handle the response from a PHP Script while using a jQuery Ajax method?</p>
  <p><strong>javascript</strong></p>
  <pre class="lang-js prettyprint-override"><code>$.ajax({
      type: 'post',
      url: 'show.php',
      data: {name: name},
      dataType: 'json',
      success: function(response) {
         //I want my json response back here
      }
  });
  </code></pre>
  <p><strong>show.php</strong></p>
  <pre class="lang-php prettyprint-override"><code>$hostelName = $_POST['name'];
  $sql = //here is the actual sql containing the $hostelname
  $query = mysql_query($sql);
  $obj = mysql_fetch_object($query); 
  $sum = $obj-&gt;sum;
  $tour = $obj-&gt;tour;
  echo json_encode(
      array(
          &quot;sum&quot; =&gt; $sum,
          &quot;tour&quot; =&gt; $tour
      )
  );
  </code></pre>