AJAX 获取跨域 HTML
我担心我可能正在尝试做某些安全策略专门禁止的事情。
某个网站有某个基于 AJAX 的聊天应用程序。它定期轮询服务器并接收 HTML 片段作为回报。我希望编写一个替代移动前端,它使用 JS 直接查询现有后端(即不使用我的服务器作为反射器)。
这里有两个主要问题使这个问题与大多数此类问题不同:
服务器所有者不会介意我这样做,但他不会竭尽全力帮助我,因此与服务器交谈的格式是不是我可以改变的。也就是说,服务器不处理 JSON,更不用说 JSONP 了。它是 HTML 片段,但就我的目的而言,本质上是文本。
我需要有可用于手动解析的返回值。它不应该通过包含在 DOM 或其他类似机制中来自动解析/插入/你有什么。
如果有人对此事有任何建议,我将非常感激。
I fear I may be trying to do something that certain security policies are specifically designed to forbid.
So there's a certain site with a certain AJAX-based chat application. It periodically polls the server and receives HTML fragments in return. I am looking to write an alternate mobile frontend that directly queries the existing backend using JS (i.e. does not use my server as a reflector).
Two main issues here that make this different from most such questions:
The server owner wouldn't mind me doing this but he's not going to go out of his way to help me, and so the format for talking with the server is not something I can change. That is, the server doesn't talk JSON let alone JSONP. It's HTML fragments but for my purposes that's essentially text.
I need to have the return value available to parse manually. It should not be automatically parsed/inserted/what-have-you through inclusion in the DOM or some other such mechanism.
If anyone has some advice on this matter, I would really appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Access-Control-Allow-Origin: example.com
)。Access-Control-Allow-Origin: example.com
).你能创建一个 php 代理吗?
ajax发送url以获取本地php(或其他服务器端脚本)
php 使用curl 来获取该页面并返回结果。
could you create a php proxy,
ajax send url to fetch to local php(or other serverside script)
php uses curl to fetch that page and returns result.