Use JSONP to load an html page

后端 未结 6 781
不思量自难忘°
不思量自难忘° 2020-11-27 17:13

I\'m trying to load an external page using JSONP, but the page is an HTML page, I just want to grab the contents of it using ajax.

EDIT: T

6条回答
  •  再見小時候
    2020-11-27 17:42

    I have done what you want but in my case I have control of the server side code that returns the HTML. So, what I did was wrapped the HTML code in one of the Json properties of the returned object and used it at client side, something like:

    callback({"page": "..."})
    

    The Syntax error you are facing it's because the library you're using expects json but the response is HTML, just that.

提交回复
热议问题