我有六個字段和一個搜索按鈕的搜索表單。當用戶填寫表單deatails並單擊搜索按鈕時,我需要使用jQuery ajax將表單字段值作爲json發送到服務器。如何獲取表單字段值並將其作爲json使用ajax發送到服務器jquery
然後服務器將發送搜索值並返回響應,然後我需要在ui中填充這些valuse。我需要爲jquery ajax提供示例UI代碼。請任何人都可以幫忙嗎?下面 是我的HTML表單
<form name="NAME" id="customerDetailSearchForm" action="">
<fieldset>
<legend>Search Contact</legend>
<table width="100%" cellpadding="0" cellspacing="0" class="vzuui-detailpanel">
<tr>
<td><label>Name :</label><input type="text" value="" /></td>
<td><label>City :</label><input type="text" value="" /></td>
<td><label>Phone :</label><input type="text" value="" /></td>
</tr>
<tr>
<td><label>Address :</label><input type="text" value="" /></td>
<td><label>State Prov :</label><input type="text" value="" /></td>
<td><label>Email :</label><input type="text" value="" /></td>
</tr>
</table>
</fieldset>
<button class="vzuui-btn-red-active closeedit" type="button" id="search">Search</button>
'$( '#customerDetailSearchForm')。序列化()'會抓住所有的'data'從'form' – Rayon
jQuery的。 com將 – pathfinder
$('#customerDetailSearchForm')。serialize()存儲到單個變量併發送到服務器 –