1

This code fetches the HTML source of http://www.foo-example-site.com/(index.html)

$.ajax({ url: 'http://www.foo-example-site.com', success: function(data) {
    alert(data); 
    } 
}); 

However, the website changes the content of HTML source depending on User Agent.
If I want to switch User Agent to this below only when using ajax request, how can I fix my code?

Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
0

1 Answer 1

2

No, this is part of the HTTP protocol. You can change it in the browser, but not in an AJAX call.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. Is there any trick to let user's browser to grab external HTML source with customized User Agent params?
You need to write a browser plug-in to do that.
It seems too much work:( what if I use PHP or RUBY? Is it feasible?
You can do that using CURL on the server, but not on the browser.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.