在<li>
點擊我的點擊值設置爲隱藏輸入這樣值分配給輸入,需要兩個職位
$(".total").click(function() {
$("input[name=hid4]").val("4");
});
我<li>
還張貼我的形式使用Ajax的頁面,它得到所有數據並返回它。
然而,在該網頁上我要求我只設置上點擊,var getVal = request.form["hid4"];
的值,然後進行測試我只是寫出來這樣<a>@getVal</a>
,它需要2個員額它更新之前,這是爲什麼?我怎麼能讓它在第一篇文章後更新?
Ajax代碼:
function mySubmit(theForm) {
theForm = $(theForm).closest("form");
$.ajax({ // create an AJAX call...
data: $(theForm).serialize(), // get the form data
type: $(theForm).attr('method'), // GET or POST
url: $(theForm).attr('action'), // the file to call
success: function (response) { // on success..
$('#here').html(response); // update the DIV
}
});
}
列表形式
<div class="holdLiftMenu">
<ul class="holdLiftMenuUL">
<li class="holdLiftMenuLI">
<a onclick="mySubmit(this)" class="holdLiftMenuA total current">Total
<input type="hidden" name="hid4" id="hid4" value="" />
</a>
</li>
</ul>
</div>
爲什麼不把'$ .ajax'調用'VAL( '4')'在不顯眼的事件處理程序後,對不對?通過這種方式,您也可以移除過時的'on *'事件屬性。 –
只需將要爲隱藏字段賦值的行添加到提交函數即可。 – Dherya
點擊你將會觸發兩個事件。 爲什麼不只使用一個onclick? –