Reputation: 4446
I am trying to get the source code of a page (let's say google.com) using Javascript. The code I tried is below but the issue remains the same which is that I am accessing a different domain. What I am trying to do is to check the source code of a page, check for a specific value in that source code and behave based on that information. Thanks!
$.get(url, function(data){ something(data); }//end function(data) );//end get
Upvotes: 0
Views: 227
Reputation: 382150
You can't do it if the page is from another domain and doesn't specifically allow it with CORS headers. See the Same Origin Policy.
The only "workaround" is using a server, either fetching the source for you or acting as proxy.
Upvotes: 2