代码是我所做的: 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);
}
});
}