我是jQuery的新手,我試圖在觸發模糊時查找文本框的行ID,但我無法使其工作到目前爲止。我試圖從帖子中獲取數組的值
當我在第一個文本框上觸發模糊事件時,我需要的全部內容就像中的form_data
。
$("input").blur(function() {
$('input').each(function (index, value) {
var form_data = $("#employee_" + index).find('input').serialize();
$.ajax({
url: "<?php echo site_url("HomeController/calculate_time_lap "); ?>",
type: 'POST',
data: form_data,
success: function (result) {
$('input').closest('tr').find('.TextBox3').val(result);
}
});
return false;
});
,這裏是我的看法頁:
<tr id="employee_0"><input type ="textbox"></tr>
<tr id="employee_1"><input type ="textbox"></tr>
<tr id="employee_2"><input type ="textbox"></tr>
<tr id="employee_3"><input type ="textbox"></tr>
<tr id="employee_4"><input type ="textbox"></tr>
請正確格式化您的代碼,以便其他人可以閱讀並幫助您。謝謝! –
我不知道你想用這個AJAX做什麼,但是請注意,如果使用'.each()'調用它,就會在任何時候觸發一個''輸入' .blur'在_any_'input'元素上。 – Alnitak