title: Making jQuery $.ajax call to Twitter API 1.1 search
body: <p>Here is a very simple example of a call to Twitter's search API to get all tweets from a tag known to have tweets, #fml. </p>
  
  <p>I believe I am correctly using the application-only authentication as explained here: <a href="https://dev.twitter.com/docs/auth/application-only-auth" rel="nofollow">https://dev.twitter.com/docs/auth/application-only-auth</a> (see Step 3 for example of a call)</p>
  
  <p>I am being asked for a solution that does not involve any server-side code so I am including the bearer code in the javascript, which isn't good to begin with, but....</p>
  
  <p>I would expect this code to work. Instead it produces the error '400 (Bad Request)'. Any ideas?</p>
  
  <pre><code>$.ajax({
      url: "https://api.twitter.com/1.1/search/tweets.json",
      dataType: "jsonp",
      data: "q=%23fml",
      beforeSend:  function (xhr) { 
               xhr.setRequestHeader ("Authorization", "Bearer XXmyBearerCodeXX"); 
              },
      success: function(json){ alert(json); }
  });
  </code></pre>
  
  <p><strong>EDIT 1 - Validated Twitter call</strong></p>
  
  <p>Using <a href="http://hurl.eu" rel="nofollow">hurl.eu</a> I was able to get a successful response from the API with the above query and Authorization header, so I assume this means my Twitter call is correct, just not set up correctly within jQuery.ajax(), but I just don't see what is missing.</p>