Question

I'm trying to use jquery to load a local html page and display an alterated version of it. I think I can do the alteration just fine, but I can't seem to load the page because it contains malformed tags such as unclosed IMG or BR tags, or </ characters, which is normally ignored by web browsers

but when I'm using the $.get("mypage.html"); command, firefox's javascript console shows an error telling me about the malformed tags and in the end, the ajax response only contains the page which send the ajax request (that's normal considering the loading failed)

I'm guessing the solution would be to load the html page as plain text so firefox won't catch a malformed tag error but I can't manage to force the response type and so, I always get the same error.

so far, I tried to set the ajax plugin like so :

$.ajax({
  contentType: "text/plain; charset=utf-8",
  dataType : "text",
  success: function(data) {
    alert(data);
  }
});

contentType and dataType settings give me a responseText but the load still fails so it contains the source code of the calling page

is there really no solution to this problem ? besides the obvious "manually correct the tags in the html pages"

I have to add that all of this is local, there won't be any server processing involved.

I'm using the latest firefox (20) and the jquery (1.9.1) updates to this day

Was it helpful?

Solution

XMLHttpRequest triggers an HTTP request; therefore, I'm pretty sure that you can't avoid an HTTP server being involved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top