在accordion条目上通过JQuery AJAX在accordion之外更改div中的内容(需要是a)

在accordion条目上通过JQuery AJAX在accordion之外更改div中的内容(需要是a),jquery,ajax,html,jquery-ui-accordion,Jquery,Ajax,Html,Jquery Ui Accordion,我希望有一个jqueryui作为菜单,当单击其中的一个条目时,通过菜单旁边的DIV更新主内容区域中的内容 我需要向添加什么,以便它调用jQueryAjax,从而更新主div?我真的希望保留表单按钮,而不是使用表单按钮。我在这里查看了一下,也在谷歌上搜索了一个解决方案,但我找到的答案要么是首先使用AJAX生成手风琴,要么是更新手风琴菜单本身——这些都没有帮助我解决问题 请帮帮我,我只是不知道该怎么办!谢谢 代码: 以及: 更新1-截至目前的完整工作代码: index.html: <html&

我希望有一个jqueryui作为菜单,当单击其中的一个条目时,通过菜单旁边的DIV更新主内容区域中的内容

我需要向添加什么,以便它调用jQueryAjax,从而更新主div?我真的希望保留表单按钮,而不是使用表单按钮。我在这里查看了一下,也在谷歌上搜索了一个解决方案,但我找到的答案要么是首先使用AJAX生成手风琴,要么是更新手风琴菜单本身——这些都没有帮助我解决问题

请帮帮我,我只是不知道该怎么办!谢谢

代码:

以及:

更新1-截至目前的完整工作代码:

index.html:

<html>
<head>
<link href="../style.css" rel="stylesheet" type="text/css">
<script src="../jquery-1.8.3.js"></script>
<script src="../jquery-ui.js"></script>
</head>

<body>
<script type="text/javascript">
$(function() {
$("#nav").accordion({
active: false,
collapsible: true
});
});

jQuery(function($){
$("#nav").on("click", "a", function(event){
$('#main').load(this.href);
event.preventDefault();
});
});
</script>

<div id="nav">
<h3><a href="">Home</a></h3>
<h3>Select below:</h3>
<div>
<ul>
  <li><a href="loadContent.php?page=1">This link shows the content of page 1</a></li>
</ul>
</div>
</div>

<div id="main">
This is the main content area:
Here is the default content shown when the page loads
and needs to be replaced when one of the menu entries
are selected but without loading the whole page, thus
via AJAX and DIV update; also the content is provided
via a PHP file that reads it out from a DB.
</div>
</body>
</html>
和loadContent.php:

<?php
$request = $_REQUEST['page'];
if (!$request) {
$outputStr = "This is the default content...";
}
else {
$outputStr = "New content: 'page' value = ".$request;
}
exit($outputStr);
?>
您可以使用:


你的ajax代码在哪里?@Ghommey:Hi-我有一个使用ajax的实现,但是:1。被替换为一个表单按钮,这是可行的,但我需要的是到位,而不是一个按钮;2.AJAX代码不是来自JQuery的代码,如果可能的话,我更愿意使用JQuery。如果发布非JQuery AJAX代码对我有帮助,我可以,但这并不是必须的——如果你不这么认为,请在这里发布另一条评论,我会的。谢谢您知道如何通过AJAX加载内容吗?AJAX是从服务器端loadContent.php提供的,通过将内容从数据库中取出到数据库中来加载内容?或者我不需要AJAX吗?因为href,现在它使用page1.php。但是使用.loadcontent.php也可以,你有两个h3标题要删除one@MikeyJStackOverflow不是一个讨论板,而是一个问答系统。这样做的目的是收集尽可能多的一般性问题。因此,您可能会将有关隐藏链接的问题转到新链接中。或者搜索它,可能之前已经有人问过:
<html>
<head>
<link href="../style.css" rel="stylesheet" type="text/css">
<script src="../jquery-1.8.3.js"></script>
<script src="../jquery-ui.js"></script>
</head>

<body>
<script type="text/javascript">
$(function() {
$("#nav").accordion({
active: false,
collapsible: true
});
});

jQuery(function($){
$("#nav").on("click", "a", function(event){
$('#main').load(this.href);
event.preventDefault();
});
});
</script>

<div id="nav">
<h3><a href="">Home</a></h3>
<h3>Select below:</h3>
<div>
<ul>
  <li><a href="loadContent.php?page=1">This link shows the content of page 1</a></li>
</ul>
</div>
</div>

<div id="main">
This is the main content area:
Here is the default content shown when the page loads
and needs to be replaced when one of the menu entries
are selected but without loading the whole page, thus
via AJAX and DIV update; also the content is provided
via a PHP file that reads it out from a DB.
</div>
</body>
</html>
<?php
$request = $_REQUEST['page'];
if (!$request) {
$outputStr = "This is the default content...";
}
else {
$outputStr = "New content: 'page' value = ".$request;
}
exit($outputStr);
?>
jQuery(function($){
    $("#nav").on("click", "a", function(event){
       $('#main').load(this.href);
       event.preventDefault();
    });
});