1

In my Google Chrome Extension, I want to store the page source of a URL input by the user in a string and then parse it.

I found similar questions and I tried the following methods:

var titleList = $.getJSON(URL);

Error: No 'Access-Control-Allow-Origin' header is present on the requested resource.

$.get(URL, function (response) {
    alert(response)
});

Error: GET chrome-extension://lcacjlgephhfpadlaehfejnlkgpnacfg/www.google.com net::ERR_FILE_NOT_FOUND

xennygrimmato
  • 2,646
  • 7
  • 25
  • 47
  • Your code may get the source but when you try to read the page source from one domain to another domain this problem occurs if another domain does not allow this. for more got to: [how-does-access-control-allow-origin-header-work](http://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work) – garish Jul 29 '14 at 09:13
  • Do you have host permissions for the resource you're trying to fetch? – Xan Jul 29 '14 at 11:09
  • I don't have any permissions as such. But I just want the HTML source of that page, nothing else. So, if that is publicly viewable, why should I need permissions? – xennygrimmato Jul 29 '14 at 12:09

1 Answers1

0

You can use XMLHttpRequest in order to to load any text base files rendering markup.

  • 1
    Important: to circumvent CORS in a Chrome extension, you need host permissions. – Xan Jul 29 '14 at 11:08