title: jQuery - Illegal invocation
body: <p><strong>jQuery v1.7.2</strong></p>
  
  <p>I have this funcion that is giving me the following error while executing :</p>
  
  <pre><code>Uncaught TypeError: Illegal invocation
  </code></pre>
  
  <p>Here's the function :</p>
  
  <pre><code>$('form[name="twp-tool-distance-form"]').on('submit', function(e) {
      e.preventDefault();
  
      var from = $('form[name="twp-tool-distance-form"] input[name="from"]');
      var to = $('form[name="twp-tool-distance-form"] input[name="to"]');
      var unit = $('form[name="twp-tool-distance-form"] input[name="unit"]');
      var speed = game.unit.speed($(unit).val());
  
      if (!/^\d{3}\|\d{3}$/.test($(from).val()))
      {
          $(from).css('border-color', 'red');
          return false;
      }
  
      if (!/^\d{3}\|\d{3}$/.test($(to).val()))
      {
          $(to).css('border-color', 'red');
          return false;
      }
  
      var data = {
          from : from,
          to : to,
          speed : speed
      };
  
      $.ajax({
          url : base_url+'index.php',
          type: 'POST',
          dataType: 'json',
          data: data,
          cache : false
      }).done(function(response) {
          alert(response);
      });
  
      return false;
  });
  </code></pre>
  
  <p>If I remove <code>data</code> from ajax call, it works .. any suggestions?</p>
  
  <p>Thanks!</p>