【发布时间】:2012-09-05 09:03:12
【问题描述】:
我在 wordpress 的后端有这个按钮,如果单击它,它应该从我的主题的一个文件中更改一个 div 的内容。我的代码可能离我应该去的地方很远......
<input type="submit" value="load()" id="start_chat" /> //the button
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$.ajaxSetup ({
cache: false
});
var loadUrl = "facut_mine3.php"; // the file where there is only a new content for the div #eu_la
$("#start_chat").click(function(){
$("#eu_la").load('http://www.fattorefamiglia.com/wp-content/themes/child_care_creative/layout_home_page2.php').html(loadUrl); //this is the file that I want to change, with the div #eu_la
});
</script>
当然,当我单击按钮时没有任何变化。有没有其他方法可以做到这一点?
【问题讨论】:
-
将错误处理代码放入您的 ajax 调用中以找出您遇到的错误。
-
您的意思是我不能从不同的文件更改文件的内容?没有解决办法?
-
@Ashish 我不知道该怎么做,我在谷歌上找不到怎么做。有链接吗?
-
而不是 $().load() 使用 $.ajax() 你可以在api.jquery.com/jQuery.ajax找到更多关于 $.ajax 的信息
-
让它变得简单。您在页面上有一些内容。当你点击一个按钮时,你需要在那个地方显示一些其他的内容。这是你的终极目标吗??