如何在php中的每个dyanamically添加行调用ajax函数

时间:2015-06-29 07:58:02

标签: javascript php jquery ajax

Ajax功能如下

<script type="text/javascript"> 
        function getStudentDetails() {
            var userName = document.getElementById("getName").value;
            $.ajax({
                type : "POST",
                cache : false,
                data : {name:userName},
                url : "get_project_details.php",
                success : function(student_details) {
                    var resArr = JSON.parse(student_details);

                    document.getElementById("pname").value = resArr[0];                       
                }
            });
        }
</script>

我正在使用具有以下功能的数据表

function addRow(tableID) {
    var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    if(rowCount < 10) {                     
        // limit the user from creating fields more than your limits
        var row = table.insertRow(rowCount);
        var colCount = table.rows[0].cells.length;


        for(var i=0; i<colCount; i++) {
            var newcell = row.insertCell(i);
            newcell.innerHTML = table.rows[0].cells[i].innerHTML;

            // tooltip code for each row



             // re-instantiate tooltip after the new ones are added since there is no eventhandler attached to them. (calling tooltip function here)
        //$onChange=getStudentDetails();
        $('[data-toggle="tooltip"]').tooltip();     

        }
    }
    else
    {
         alert("Allowed maximum items per indent is 10. Please raise one more indent if required");

    }
}

当我选择项目编号时,项目名称出现在下一个字段中,但添加另一行后Ajax函数getStudentDetails()无法正常工作

0 个答案:

没有答案