【问题标题】:Including php page in html page在html页面中包含php页面
【发布时间】:2014-05-11 05:58:04
【问题描述】:

这里我试图在 html 页面中访问一些 php 页面。两者都在不同的服务器上运行,一个在 WAMP 服务器上,当我点击

时,我可以在浏览器中看到该页面
http://localhost:8080/winnersphp/index.php

现在我正在尝试在 ajax 加载中访问该页面,就像在 localhost 中的不同服务器(在 Eclipse 中,它是码头服务器(java))中运行的另一个 html 页面一样,页面 URL 是

http://localhost:8888/includephp.html

在这个 html 页面中我使用的是 Jquery

<script>
    $( document ).ready(function() {
    $("#externalHeader").load("http://localhost:8080/winnersphp/index.php");
    });
</script>

但没有运气。有什么安全问题吗??还是域问题??

最初我考虑了一些域问题,但都在本地主机上运行。端口在这里有什么问题吗?

有人可以指出我在这里缺少什么吗?

【问题讨论】:

  • 控制台有错误吗?
  • @NateKibler 刚刚交叉检查。没有。没有错误。 :-/

标签: javascript php jquery html cross-domain


【解决方案1】:

貌似jQuery的.load()方法类似于.get()函数,受制于same origin policy。这确实限制了不同的端口号。

如果您可以使用JSONP,您仍然可以按照以下答案完成任务:https://stackoverflow.com/a/2099771/2482557

【讨论】:

  • 感谢您的回答。会调查的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-13
  • 2015-07-12
  • 1970-01-01
  • 1970-01-01
  • 2011-01-14
  • 1970-01-01
相关资源
最近更新 更多