gpt4 book ai didi

javascript - 从网页获取数据,然后在另一个网页上显示

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:27:07 24 4
gpt4 key购买 nike

我想从一个 HTML 网页获取数据,然后使用 jQuery 在另一个 HTML 网页的 Div 中显示它。

我尝试了 jQuery 的 get()、load() 和 ajax() 方法,但无法获取数据。这是我的代码:

http://jsfiddle.net/YcprC/

  • 我的代码有什么问题?

  • 是否可以从 ASP.NET 网页获取数据,然后将其显示在 HTML 网页上?

  • 如何从一个网页的Div中获取数据,然后在另一个网页的另一个Div中显示?

提前致谢...

最佳答案

由于所谓的同源策略,您无法从其他网站获取数据:

In computing, the same origin policy is an important security concept for a number of browser-side programming languages, such as JavaScript. The policy permits scripts running on pages originating from the same site to access each other's methods and properties with no specific restrictions, but prevents access to most methods and properties across pages on different sites.1

要解决这个问题,您应该实现 JSONP .了解更多 here .

或者您也可以使用 Yahoo 的 YQL,请参阅:

关于javascript - 从网页获取数据,然后在另一个网页上显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9340944/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com