title: Ajax running function inside my Class prototype?
body: <pre><code>function MyClass() {
      this.test = function () {
          return 'foo';
      }
  }
  MyClass.prototype.myMethod = function (data) {
      alert(data.name);
  }
  var newClass = new MyClass();
  setTimeout(function () {
      $.ajax({
          url: '/echo/html/',
          data: newClass,
          success: function (data) {
              console.log('in success callback');
              console.log('received data: ' + data);
          }
      });
  }, 3000);
  </code></pre>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'name' of undefined </p>
  </blockquote>
  
  <p>Why does ajax trigger <code>newClass.myMethod</code>? because of JSON parsing? how to avoid this error?</p>
  
  <h2><a href="http://jsfiddle.net/4CLpg/" rel="nofollow">jsFiddle</a></h2>