构建动态创建的 Clickable Divs JQuery Ajax
我需要一些 jQuery ajax 帮助。 我当前有一个主要内容 div,它由对 XML 文件的 ajax 调用填充。 XML 文件是从数据库结果集生成的。这一切工作正常。 ajax 调用是通过单击按钮触发的,但我希望更改它。
我有另一个 div,其中填充了标题列表。我希望发生的是,当单击标题时,应使用与该标题相关的数据更新主要内容 div。我想知道什么是最好的方法来做到这一点。我应该创建一个可点击的 div 来进行 ajax 调用吗?如果是这样,我如何区分在主要内容 div 的代码中单击了哪个 div。我希望这是有道理的...... 这是我的填充列表的代码
$(document).ready(function() {
$("#getData").click(function() {
var $title = "";
$.get("phpAjaxMovieListingTotal.php", function(theXML) {
$('row',theXML).each(function(i) {
$title = $(this).find("Title").text();
});
$("#movieListingContentDiv").html($title);
});
});
});
I need some jQuery ajax help.
I currently have a main content div that is populated by an ajax call to a XML file. The XML file is generated from a db resultset. This is all working fine. The ajax call is fired by a button click but I wish to change that.
I have another div which I have populated with a list of titles. What I wish to happen is when a title is clicked the main content div should be updated with data related to that title. I was wondering what would be the best way to do this. Should I create a clickable div that makes an ajax call? and if so how do I distinguish which div has been clicked in the code for the main content div. I hope this makes sense......
here is my code for the populated list
$(document).ready(function() {
$("#getData").click(function() {
var $title = "";
$.get("phpAjaxMovieListingTotal.php", function(theXML) {
$('row',theXML).each(function(i) {
$title = $(this).find("Title").text();
});
$("#movieListingContentDiv").html($title);
});
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,有关从 xml 加载的可点击 div 的列表,请查看演示。
演示
这是代码:
Alright, for a list of clickable divs, loaded from the xml, look at the demo.
The Demo
Here is the code: