简体   繁体   中英

Javascript: client-side webservice with <script> tag

I'm trying to implement sort of client-side webservice client.

To get over the same server policy , i'm thinking of including the external page whose content I need to read via the <script> tag that can get cross-domain content. I have no control over the webservice being consumed, so i can't actually return javascript code (it's a simple html page returning "OK" or "KO" in the body).

It seems like I can't use src="text/html", only "text/javascript" is accepted and this yelds an obvious error as an html page can't be evaluated as javascript code.

Apart from that, how can I then read the loaded script's content? With Google Chrome's javascript console I can see that the page is loaded withing the script, only I don't know how to access it.

PS: I'm using jQuery, if this helps.

You can't. If this worked, it would expose private (eg protected by cookies) user data to third-party sites.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM