title: Asp.net MVC jQuery Ajax calls to JsonResult return no data
body: <p>I have this script loaded on a page: </p>
  
  <pre><code>(function() {
              window.alert('bookmarklet started');
              function AjaxSuccess(data, textStatus, xmlHttpRequest) {
                  if (typeof (data) == 'undefined') {
                      return alert('Data is undefined');
                  }
                  alert('ajax success' + (data || ': no data'));
              }
              function AjaxError(xmlHttpRequest, textStatus, errorThrown) {
                  alert('ajax failure:' + textStatus);
              }
              /*imaginarydevelopment.com/Sfc*/
              var destination = { url: 'http://localhost:3041/Bookmarklet/SaveHtml', type: 'POST', success: AjaxSuccess, error: AjaxError,
                  dataType: 'text',contentType: 'application/x-www-form-urlencoded'
              };
              if (typeof (jQuery) == 'undefined') {
                  return alert('jQuery not defined');
              }
  
              if (typeof ($jq) == 'undefined') {
                  if (typeof ($) != 'undefined') {
                      $jq = $;
                  } else {
                      return alert('$jq-&gt;jquerify not defined');
                  }
              }
              if ($jq('body').length &lt;= 0) {
                  return alert('Could not query body length');
              }
              if ($jq('head title:contains(BookmarkletTest)').length &gt; 0) {
                  alert('doing test');
                  destination.data = { data: 'BookmarkletTestAjax' };
                  $jq.ajax(destination);
                  return;
              }
  
          })();
  </code></pre>
  
  <p>when it is run locally in VS2008's cassini the ajax success shows the returned string from Asp.net MVC, when it is run remotely the ajax success data is null. Here's the controller method that is firing both locally and when run remotely:</p>
  
  <pre><code>    [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
      public string SaveHtml(string data)
      {
          var path = getPath(Server.MapPath);
          System.IO.File.WriteAllText(path,data);
          Console.WriteLine("SaveHtml called");
          Debug.WriteLine("SaveHtml called");
  
          //return Json(new { result = "SaveHtml Success" });
          return "SaveHtml Success";
      }
  </code></pre>
  
  <p>Once i have it working I was going to remove the GET, but currently accessing the SaveHtml method directly from the webbrowser produces the expected results when testing.</p>
  
  <p>So there's something wrong in my javascript I believe, because when I step through there with chrome's developer tools, I see the data is null, and the xmlHttpRequest doesn't appear to have the expected result in it anywhere either.</p>
  
  <p>I'm loading jquery via 
  <code>http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js</code></p>