I have a javascript file in a server I can't modify.
Here is a sample of the script I have to download:
var tags = '';
tags += '<a href="#somelink"><img src="someimage.gif"/></a>;
document.write(tags);
I started downloading the script via AJAX and executing it, but I bumped into the "document.write cannot be executed in asynchronous call" problem.
So I wanted to download the script as a plain text and take what I need from the response and put it where it should go in my html page without modyfing the original script.
$.ajax({
type: "GET",
url: "http://myurlexample.com",
dataType: "text",
}).success(function(msg){
console && console.log("The script was downloaded as text: "+msg);
}).error(function(object,status,errortxt){
console && console.log("The script wasn't downloaded as text. The error:"+ errortxt);
});
But AJAX throws an error when I do the download request using dataType = "text"
. Is there any way to go around this and actually download it as a text?
P.S: The script is for a Firefox OS privileged app, so I can't put the script directly in the html page because the security CSP doesn't allow it (https://developer.mozilla.org/en-US/Apps/CSP).