Skip to content Skip to sidebar Skip to footer

Handle Relative Image Paths Ajax

I'm developing a small Google chrome extension that screen scrapes a certain website. The problem is that because that website uses relative paths the links become broken and I get

Solution 1:

The solution is to not use jQuery to parse the document. You can use jQuery.ajax if you want to, but do not use $ to parse the result.

Read the answer to Console shows error about Content Security policy and lots of failed GET requests to understand and solve your problem.

The answer strongly recommends to use vanilla JavaScript. If you want to use jQuery nevertheless, use the following DOM parsing method:

// responseText is a string, for example from calling jQuery.ajaxvar doc = document.implementation.createHTMLDocument('');
doc.documentElement.innerHTML = responseText;
var $doc = $(doc);
// Enjoy the parsed document without errors!

Post a Comment for "Handle Relative Image Paths Ajax"