【问题标题】:Accessing variables from .load() page从 .load() 页面访问变量
【发布时间】:2014-01-06 19:04:04
【问题描述】:

我有我的 index.php 并加载让我们用 .load() 将“content.php”加载到窗口 onload 上的 div 中。
如何在我的 index.php 中使用 content.php 中的变量

例如:
假设我的 content.php 中有一个名为 $something 的变量。我想在我的 index.php 中使用该变量

在我的 index.php 中:

<head>
$(function Loadcontent() {
    $("#content").load("content.php")
});
window.onLoad = Loadcontent();
</head>
<body>
<div id="content"></div>
</body>

在我的 content.php 文件中,我现在声明一个变量:

$something = 1;

我现在想在 index.php 中使用 $something

【问题讨论】:

  • 显示一些代码将有助于回答。
  • 你使用 AJAX。
  • 不能,index.php已经被服务器渲染好了。
  • 我添加了一些伪代码。又快又脏。
  • 你能给我举个eisa adil的例子吗?

标签: php jquery variables load return


【解决方案1】:

你需要使用 Ajax,网上很多

http://www.w3schools.com/php/php_ajax_database.asp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-11
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-09
    相关资源
    最近更新 更多