Use JSONP to load an html page

后端 未结 6 780
不思量自难忘°
不思量自难忘° 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:31

    If you really just want to employ the client to snag an HTML file, I suggest using flyJSONP - which uses YQL.. or use jankyPOST which uses some sweet techniques:

    jankyPOST creates a hidden iframe and stuffs it with a form (iframe[0].contentWindow.document.body.form.name).

    Then it uses HTML5 (watch legacy browsers!) webMessaging API to post to the other iframe and sets iframe's form elements' vals to what u specified.

    Submits form to remote server...done.

    Or you could just use PHP curl, parse it, echo it, so on.

    IDK if what exactly ur using it for but I hope this helps.

    ALSO... I'm pretty sure you can JSONP anything that is an output from server code. I did this with ClientLogin by just JSONPing their keyGen page and successfully consoleLogged the text even though it was b/w tags. I had some other errors on that but point is that I scraped that output.

    Currently, I'm trying to do what you are so I'll post back if successful.

提交回复
热议问题