title: JavaScript ajax post command error for localhost
body: <p>I am new to Ajax &amp; JavaScript. But i am stuck with this error. I am making post request using Ajax. </p>
  
  <pre><code>var sentdata = {"name":"gourav", "email":"email"};
  var sentd = JSON.stringify(sentdata);
  this.url = "http://localhost/Working/board.php";
  $.ajax({
      type: "POST",
      url: $(this).url,
      data: sentd,
      contentType: "application/json",
      //dataType : "json",
      success: function (response) {
          alert(response.message);
          console.log( "Done with success: ");
      },
      error: function (xhr, thrownError) {
          alert(thrownError);
      }
  });
  </code></pre>
  
  <p>I am calling this request to simple code where i am not even checking the <code>$_POST</code> variable and just trying to write some data in mysql table.</p>
  
  <pre><code>$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true);
  // selecting database
  mysql_select_db(DB_DATABASE, $con);
  if(1)
  {
      $tb_name = "tb_appuser";
      $name = "name1";
      $email="email1";
      $deviceId="0";
      $platform="1";
      $query = sprintf("INSERT INTO %s (user_name, email, device_regid, platform_type) VALUES ('%s', '%s', '%s', '%d')" , $tb_name, $name, $email, $deviceId, $platform);
      echo "$query\n";
      $res = mysql_query($query);
  }
  </code></pre>
  
  <p>I already tested this board.php code and verified it is inserting the data in table. </p>
  
  <p>But when i am doing this via $ajax i am getting "The page at localhost says: undefined" and nothing got written in my database also.</p>