title: Trying to upload multiple data using JSON - jQuery. Why not working?
body: <p>I am developing a web application using jquery-1.5.2.js . The server to which I am trying to upload is JSON formatted. I am trying to upload four variables to the server but I get an error. My code is as follows:</p>
  
  <p>--Updated code using the suggestions below, still not working though:</p>
  
  <pre><code>image= JSON.stringify(imageEncode, replacer);
  name = JSON.stringify(name, replacer);
  id = JSON.stringify(id, replacer);
  comments = JSON.stringify(comments, replacer);
  
  function data_post(){
  $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      datatype: "json",
      url: "example/new.json",
      data: "{'image': '" + image + "', 'name': '" + name + "', 'id': '" + id + "', 'comments': '" + comments + "'}",
      success: function () {
          alert('Successfully uploaded');
      },
      error: function () {
          alert('Error on upload');
      }
  });}
  </code></pre>
  
  <p>Why do I still get an "Error on upload" message? </p>