【发布时间】:2015-05-26 00:24:21
【问题描述】:
我有以下代码,它运行良好......到目前为止。但我想接下来有一个表单加载...阅读下面的代码以获得解释。
主页:
<li><a href="content1.php" class="load-external" data-target="#right_section">Some Content</a></li>
<div id="right_section"></div>
<script>
$('body').on('click', 'a.load-external', function(e){
var target = $( $(this).attr('data-target') );
target.load( $(this).attr('href') );
e.preventDefault();
});
</script>
content1.php
<li><a href="content2.php" class="load-external" data-target="#right_section">Some Content 2</a></li>
现在,在 content1.php 中,所有链接 (a=href...) 都可以正常工作并加载到 #right_section div 中。
但在 content1.php 上,我也有一些表单,我希望它们也加载到同一个 div #right_section。表单示例如下:
content1.php 中的示例表单:
<form action="report_output.php" method="get" id="graphIt">
如何让一个表单(任何表单,页面上可能有多个)加载到 div #right_section,而不加载整个页面(现在可以)
谢谢!
【问题讨论】:
-
所有内容都应该加载到 DIV 中。我看不出表格应该不同的任何原因。
-
您是说当您提交其中一个表单时,其结果应该加载到 DIV 中,而不是重新加载页面?
-
正确...但是现在,它只是覆盖了整个浏览器窗口。
标签: javascript php jquery html forms