Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否将表中的表单元素作为ajax请求提交?_Javascript_Php_Jquery_Html_Ajax - Fatal编程技术网

Javascript 是否将表中的表单元素作为ajax请求提交?

Javascript 是否将表中的表单元素作为ajax请求提交?,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,我有一个动态生成的表,每行中都有一个编辑和删除按钮,当用户编辑输入、复选框和文本区域,单击编辑时,我需要将值发布到处理页面 如何发送包含表单元素的ajax请求,这些表单元素位于html表的这一行、特定行或仅此迭代行中? 请帮助我,我不太擅长js//首先谢谢你。 //First of all thank you. //After a deep search, I solved my own problem, here's the answer // if anyone has encounter

我有一个动态生成的表,每行中都有一个编辑和删除按钮,当用户编辑输入、复选框和文本区域,单击编辑时,我需要将值发布到处理页面 如何发送包含表单元素的ajax请求,这些表单元素位于html表的这一行、特定行或仅此迭代行中? 请帮助我,我不太擅长js

//首先谢谢你。
//First of all thank you.
//After a deep search, I solved my own problem, here's the answer 
// if anyone has encountered the same thing:
<script>
$('.editRow').on('click', function (e) {
    var data = {};
    var row = $(this).closest('tr');
    var rowData = row.find('input, checkbox, textarea');
    if (rowData.length > 0) {
        rowData.each(function () {
            data[$(this).attr('name')] = $(this).val();
            //rowData.push($(this).val());
        });
        //data=dataRow
    }
    $.ajax
    ({
        method: 'post',
        url: 'tbl_process.php',
        data: {
            data: data
        },
        success: function (data) {
            $('#content').html(data);
        }
    });
});
</script>
//经过深入研究,我解决了自己的问题,以下是答案 //如果有人遇到过同样的情况: $('.editRow')。在('click',函数(e)上{ 变量数据={}; var行=$(this).closest('tr'); var rowData=row.find('input,checkbox,textarea'); 如果(rowData.length>0){ rowData.each(函数(){ 数据[$(this.attr('name')]=$(this.val(); //rowData.push($(this.val()); }); //数据=数据行 } $.ajax ({ 方法:“post”, url:'tbl_process.php', 数据:{ 数据:数据 }, 成功:功能(数据){ $('#content').html(数据); } }); });
为每行创建不同的表单。