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.
Now, I'm doing an .ajax()
call, and I've tried a couple of things such as:
$.ajaxSetup({
beforeSend: function(request) {
request.setRequestHeader("User-Agent","MyAgentCode");
}
});
But it doesn't work.
I also tried:
$.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
});
Which isn't working either.
I only want to add a value to the User-Agent
(keeping the rest as it is). This will allow me to get the correct information from the correct server.