Use JSONP to load an html page

http://en.wikipedia.org/wiki/JSONP#Script_element_injection

Making a JSONP call (in other words, to employ this usage pattern),
requires a script element. Therefore, for each new JSONP request, the
browser must add (or reuse) a new element—in other words,
inject the element—into the HTML DOM, with the desired value for the
“src” attribute. This element is then evaluated, the src URL is
retrieved, and the response JSON is evaluated.

Now look at your error:

Uncaught SyntaxError: Unexpected token <

< is the first character of any html tag, probably this is the start of <DOCTYPE, in this case, which is, of course, invalid JavaScript.

And NO, you can’t use JSONP for fetching html data.

Leave a Comment