我有这个代码。我的问题是当我检查复选框仍然是 令人耳目一新,卷轴上升,并没有返回他的 提交页面后的位置。谁能帮我?对不起,我是ajax的新手。
<style>
.container {
border:2px solid #ccc;
width:600px;
height: 1000px;
overflow-y: scroll;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<form action="ajaxtry.php" id="searchForm">
<div id="Html2" style="position:absolute;left:0x;top:60px;width:250px;height:100px;z-index:12" class="container">
<input onclick="javascript: submit()" type="checkbox">Checkbox1
<br>
<input onclick="javascript: submit()" type="checkbox">Checkbox1
<br>
<input onclick="javascript: submit()" type="checkbox">Checkbox1
<br>
<input onclick="javascript: submit()" type="checkbox">Checkbox1
<br>
<input onclick="javascript: submit()" type="checkbox">Checkbox1
<br>
<input onclick="javascript: submit()" type="checkbox">Checkbox1
<br>
<input onclick="javascript: submit()" type="checkbox">Checkbox1
</form>
<!-- the result of the search will be rendered inside this div -->
<div id="result"></div>
<script>
// Attach a submit handler to the form
$( "#searchForm" ).submit(function( event ) {
// Stop form from submitting normally
event.preventDefault();
// Get some values from elements on the page:
var $form = $( this ),
term = $form.find( "input[name='s']" ).val(),
url = $form.attr( "action" );
// Send the data using post
var posting = $.post( url, { s: term } );
// Put the results in a div
posting.done(function( data ) {
var content = $( data ).find( "#content" );
$( "#result" ).empty().append( content );
});
});
</script>