同时获取不同ID的Ajaxresponse()

时间:2019-11-19 05:26:50

标签: javascript asp.net foreach modal-dialog asp.net-ajax

代码是我所做的: see image for different id's and common class that trigger click at a same time 一次获取所有ID并触发点击事件

$(".respond").each(function() {
    $(this).trigger('click');
    console.log($(this)[0].id);
    ajaxResponse();
});
 function ajaxResponse() {
    $.ajax({
        url: '/sendPostResponseAction.action',
        data: $("#postForm").serialize(),
        type: 'POST',
        success: function(data) {
            $("#respButt").removeAttr("disabled");
            console.log(data);
            $.each(data.post, function(i, data) {
                var customerName = data.post.customer.name;
                var address = data.post.address;
                var city = data.post.city;
            });
            $.each(data.postResp, function(i, data){
                var state = data.postResp.post.state;
                var zipCode = data.postResp.post.zipCode
            });
            alert(customerName +" " + address + "," + city + "," + state + "," + zipCode);
        }
    });
}

0 个答案:

没有答案