Javascript 从ajax调用ajax函数
单击按钮并调用insert时调用以下代码 _所有函数都是ajax函数。在成功的情况下,我发出了一个警报,但不起作用,json调用liquidations\u a\u insert\u all.jsp工作正常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({
$(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);
}
});
}