title: How to add a value to User-Agent header in a .ajax request?
body: <p>I'm trying to create a plugin for Chrome where I retrieve info from several pages, some of them they have a load balancer and need a specific user agent code to route me to the correct place.</p>
  
  <p>Now, I'm doing an <code>.ajax()</code> call, and I've tried a couple of things such as:</p>
  
  <pre><code>$.ajaxSetup({
      beforeSend: function(request) {
          request.setRequestHeader("User-Agent","MyAgentCode");
      }
  });
  </code></pre>
  
  <p>But <strong>it doesn't work</strong>.</p>
  
  <p>I also tried: </p>
  
  <pre><code>$.ajax({ 
      url: "http://blablabla.com/",
      dataType:'html', 
      beforeSend: function (req) {
          req.setRequestHeader('User-Agent', 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1 MyAgentCode);
      },
      error: function() { alert("No data found");},
      success: parseResult
  });
  </code></pre>
  
  <p>Which isn't working either.</p>
  
  <p>I only want to add a value to the <code>User-Agent</code> (keeping the rest as it is). This will allow me to get the correct information from the correct server.</p>