Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.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调用ajax函数_Javascript_Jquery_Json_Ajax_Jsp - Fatal编程技术网

Javascript 从ajax调用ajax函数

Javascript 从ajax调用ajax函数,javascript,jquery,json,ajax,jsp,Javascript,Jquery,Json,Ajax,Jsp,单击按钮并调用insert时调用以下代码 _所有函数都是ajax函数。在成功的情况下,我发出了一个警报,但不起作用,json调用liquidations\u a\u insert\u all.jsp工作正常 $(document).ready(function() { $('#click1').click(function(event) { var auditorid = $('input:hidden[id=Wauditorid]').val(); $.ajax({

单击按钮并调用insert时调用以下代码 _所有函数都是ajax函数。在成功的情况下,我发出了一个警报,但不起作用,json调用liquidations\u a\u insert\u all.jsp工作正常

$(document).ready(function() {
 $('#click1').click(function(event) {
     var auditorid = $('input:hidden[id=Wauditorid]').val();
     $.ajax({
         type: 'GET',
         url: 'groupauditors.jsp',
         data: {
             Woauditorid: auditorid
         },
         dataType: 'json',
         success: function(data) {
             $.each(data, function(index, element) {
                    var currRow = $("#tr0").clone().appendTo($('#items')).attr('id','tr' + (index + 1));
                    currRow.find('td:eq(0)').html(index + 1);
                    currRow.find('.subgroupid').html(element.subgroupid);
                    currRow.find('.auditorid').html(element.auditorid);

                    insert_all(element.auditorid, "", "");
             });
         }
        });
    });
});
调用insert_all(element.auditorid,“,”)


有什么想法吗

我希望在两个ajax函数中都使用
async:false、

$(document).ready(function() {
 $('#click1').click(function(event) {
     var auditorid = $('input:hidden[id=Wauditorid]').val();
     $.ajax({
         type: 'GET',
         url: 'groupauditors.jsp',
         data: {
             Woauditorid: auditorid
         },
         async:false,
         dataType: 'json',
         success: function(data) {
             $.each(data, function(index, element) {
                    var currRow = $("#tr0").clone().appendTo($('#items')).attr('id','tr' + (index + 1));
                    currRow.find('td:eq(0)').html(index + 1);
                    currRow.find('.subgroupid').html(element.subgroupid);
                    currRow.find('.auditorid').html(element.auditorid);

                    insert_all(element.auditorid, "", "");
             });
         }
        });
    });
});


function insert_all(auditorid, onSuccess, onFail) {
 $.ajax({
         type: 'GET',
         url: 'liquidations_a_insert_all.jsp',
         data: {
             Wauditorid: auditorid
         },
         async:false,
         dataType: 'json',
         success: function(data) {
                    alert("insert_all");
//$( 'table tbody tr td:last-child').html(data.inserted);
                    }
     });
 }

可能返回的数据不是json类型您检查过了吗?您确定实际调用了
insert\u all
吗?Pekka您是对的,我的jsp标记破坏了json类型。请接受我的ans
$(document).ready(function() {
 $('#click1').click(function(event) {
     var auditorid = $('input:hidden[id=Wauditorid]').val();
     $.ajax({
         type: 'GET',
         url: 'groupauditors.jsp',
         data: {
             Woauditorid: auditorid
         },
         async:false,
         dataType: 'json',
         success: function(data) {
             $.each(data, function(index, element) {
                    var currRow = $("#tr0").clone().appendTo($('#items')).attr('id','tr' + (index + 1));
                    currRow.find('td:eq(0)').html(index + 1);
                    currRow.find('.subgroupid').html(element.subgroupid);
                    currRow.find('.auditorid').html(element.auditorid);

                    insert_all(element.auditorid, "", "");
             });
         }
        });
    });
});


function insert_all(auditorid, onSuccess, onFail) {
 $.ajax({
         type: 'GET',
         url: 'liquidations_a_insert_all.jsp',
         data: {
             Wauditorid: auditorid
         },
         async:false,
         dataType: 'json',
         success: function(data) {
                    alert("insert_all");
//$( 'table tbody tr td:last-child').html(data.inserted);
                    }
     });
 }