我一直在使用此代码
<script>
$(document).ready(function() {
$.ajaxSetup({ cache: false }); //stops it caching the values so form can be change and the result updated without need for refreshing the page
});
$(function() {
$('#select_user').live('submit', function(e) {
e.preventDefault(); // stops form from submitting naturally
$.ajax({
data: $(this).serialize(),
url: $(this).attr('action') , //gets the form url from the atribute 'action' on the form.
success: function(response) {
$('#result').html(response);
}
});
});
});
</script>
太生成ajax请求并将变量从表单传递到另一个文件,这很正常。输出到div'result'的文件有另一种形式,我希望它传递给加载到'result'的文件中的另一个div。我希望只是复制代码更改不同的表单名称和输出div但这从来没有奏效。关于我如何做到这一点的任何想法。
试图尽我所能解释,我知道它有点令人困惑!
谢谢!