0
更新中.....JQuery - 使用數據刷新Div,不使用IE
我是JQuery的新手,我被困在這個上,希望有人能幫助我。我正在嘗試刷新DIV中的數據而不重新加載整個頁面。因爲這個頁面很大,所以我試圖總結一下。
--- This form is right after the body, not wrab with DIV or anything, no submit button. I want to submit the value in the textbox when user hit ENTER key.
<form name="form1" id="form1" method="post" action="PurchaseRequestList.asp">
<input type="text" name="CompanyName" id="CompanyName" value="" class="box2">
</form>
--- Below the form is the DIVs, where I like to refresh the data everytime user enter in the CompanyName textbox and hit Enter key.
<div id="div1-wrapper">
<div id="div1" style="border:solid 1px red; width: 100%;">
<table width="90%" align="center" class="RowDetail">
<-- This is where the loop using ASP to display the data -->
</table>
</div>
</div>
到目前爲止,我有這樣的代碼,但它不能用作DIV中的只刷新數據。
$(document).ready(function() {
$('#CompanyName').on('keypress', function(e) {
if (e.keyCode == 13)
{
var data = $('form').serialize();
$.ajax({
method: 'post',
data: data,
url: 'PurchaseRequestList.asp?#div1',
success: function(res) {
$('#div1-wrapper').load(url + ' #div1');
}
});
}
});
});
我很感謝你們正在幫助。讓我知道如果你需要我澄清任何。
謝謝
我都嘗試,但沒有運氣。感謝您試圖提供幫助。 – milacay
笏有問題嗎? –
我試了兩次,它重新加載整個頁面,而不是隻是DIV1。對不起,我必須在這裏做錯事。 – milacay