weixin_33712987 2010-01-02 17:13 采纳率: 0%
浏览 19

AJAX不适用于jQuery

I want to load in <div class="test"> some content from another URL ex: http://someurl.com/default.aspx.

I tried this code:

$(".test").load( 'http://someurl.com/default.aspx');

But it doesn't work.

With local file it works, but not with http://...

Can somebody help me?

Thanks

  • 写回答

3条回答 默认 最新

  • weixin_33686714 2010-01-02 17:15
    关注

    It looks like you have bumped into the same origin policy. You have to use a relative path for the load() method, otherwise most browsers will simply return an empty responseText.

    As one possible workaround, you could set up a very simple reverse proxy (using mod_proxy if you are on Apache). This would allow you to use relative paths in your AJAX request, while the HTTP server would be acting as a proxy to any "remote" location.

    The fundamental configuration directive to set up a reverse proxy in mod_proxy is the ProxyPass. You would typically use it as follows:

    ProxyPass     /ajax/     http://someurl.com/
    

    In this case, the browser would be requesting /ajax/default.aspx but in fact the server would serve this by acting as a proxy to http://someurl.com/default.aspx.

    If you are using IIS, you may want to use the Managed Fusion URL Rewriter and Reverse Proxy to set up a reverse proxy.

    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况