title: I need to pass a JSON object to a javascript/ajax method for a WCF call. How can I do this?
body: <p>So I have been looking around at many different examples of such a thing.  Most people are using a JSON serializer/deserializer or stringify method.  I have attempted to try a similar thing and unfortunately I always get an error from Google's Chrome debugger console saying:
  Uncaught ReferenceError: JavaScriptSerializer is not defined or something similar.</p>
  
  <p>Below is the actual method where I try to do a PUT operation using the information.</p>
  
  <pre><code>  function insertjsonMyUser(person) {
  
          document.write("Inside the parameter based insertion method&lt;br/&gt;");
          alert("Entered the method, right before the ajax call");
          $.ajax({
              type: "PUT",
              url: 'http://localhost/MyService/Service.svc/json/CreateUserInfo',
              contentType: "application/json",
              data: {"User" : person.User ,"Pword" : person.Pword,"FName" : person.FName,"LName" : person.LName,"JobTitle" : person.JobTitle,"CompanyName" : person.CompanyName,"CompanyBranch" : person.CompanyBranch,"PhoneNum" : person.PhoneNum,"Email" : person.Email},
              beforeSend: function(xhr) {
                  xhr.setRequestHeader('Authorization', 'default default');
              }
          });
          alert("The user has been created according to your specifications");
  
  }
  </code></pre>
  
  <p>I want person to be a JSON object using the specified Keys I have under data.  I have successfully done a similar method, but I don't want to use a hard-coded JSON object such as:</p>
  
  <pre><code>{"User" : "Zuser" ,"Pword" : "password","FName" : "firstname","LName" : "lastname","JobTitle" : "jobtitle","CompanyName" : "companyname","CompanyBranch" : "companybranch","PhoneNum" : 3123123123,"Email" : "email"}
  </code></pre>
  
  <p>The JSON object I use in the hard-coded version is the object above.  Is there something I am missing for using the methods stringify or serialize?  Also, is there an easier way than those that I have missed in my hours of searching?</p>
  
  <p>Finally, I am running Windows 7 Enterprise, using IIS hosting, and using Visual Studio 2010 for editing. My Service works fine.  I tested it in Fiddler successfully.</p>