title: Sending data over chrome extension to REST
body: <p>I am trying to send my selection to a server using post and server need REST, Tested my data with Advanced Rest Client and all works well, But when I try from my chrome extension I am getting undefinded error. Here is what I am trying  </p>
  
  <pre><code>chrome.runtime.sendMessage({
              method: 'POST',
              action: 'REST',
              headers: {'Remote-User':'myuser'},
              url: 'http://myserver/data/add/',
              data: {'content': 'the paste content'}
          }, function(responseText) {
              alert(responseText);
          });
  </code></pre>
  
  <p>Any help much appreciated, thanks </p>
  
  <p><strong>Update</strong> </p>
  
  <p>Based sdc, I changed my code like this and still responseText is undefined :(</p>
  
  <pre><code>function genericOnClick(info, tab) 
  {
      var url = 'http://mysite/data/add/';
      var data = $.toJSON({'content': 'the paste content'});
      $.ajax({
        headers: {
          'Remote-User':'username',
          'Content-Type':'application/json;charset=utf-8'
        },
        url: url,
        data: data,
        method: 'POST',
        dataType: 'json',
        error:  function(xhr, status, error){
          alert(xhr.responseText);
        },
        success: function(data){
          console.log('succes: '+data);
        }
  
      });
  }
  </code></pre>