【问题标题】:Ajax loading data from a different fileAjax 从不同的文件加载数据
【发布时间】:2014-04-06 18:20:35
【问题描述】:

谁能告诉我为什么这不起作用

<script>
$(document).ready(function() {
  $("#driver").ready(function(event){
    $('#stage').load('index.php');
  }); 
});
</script>

我在 index.php 上有一个带有链接的表格,问题是很难点击其中一个链接,我必须点击 10 次才能使其工作,有什么想法吗?

索引.php

<script>
$(document).ready(function() {
    $('#stage').load('index.php');
});
</script>
<table width="200" border="1">
  <tr>
    <td>Name </td>
    <td>URL Address</td> 
  </tr>
  <tr>
    <td><a href="https://www.google.com/">Googe</a></td> 
    <td><a href="https://www.google.com/">Google</a></td>
  </tr> 
</table>

我在 index.php 中包含相同的功能,想法是如果在索引页面上进行更改,并在测试页面上反映更改。

【问题讨论】:

  • 尝试使用class而不是id
  • 我猜你的 index.php 有一些脚本,比如 jQuery 和其他 JS 文件。因此,当您将它们加载到 DOM 时,您的页面可能会冻结一段时间。
  • 删除第二个ready(function)
  • 谢谢,我删除了 ready(function) 的第二行,但我仍然遇到同样的问题,很难建立链接来工作
  • 如果从 index.php 中删除 load 调用会发生什么?

标签: html css ajax


【解决方案1】:

ready事件只在文档上触发,去掉$("#driver").ready(部分。

$(document).ready(function() {
    $('#stage').load('index.php');
});

【讨论】:

  • 谢谢我试试这个,但我很难点击其中一个链接得到相同的结果
  • @CarlosPerez 发布 index.php 的 html。
  • 检查我的帖子更新,感谢您尝试帮助我
猜你喜欢
  • 1970-01-01
  • 2013-08-31
  • 2012-08-10
  • 1970-01-01
  • 2015-06-26
  • 1970-01-01
  • 2019-04-28
  • 1970-01-01
  • 2016-06-24
相关资源
最近更新 更多