The following codes worked before but would not work again except I put alert after the ajax call, I’ve use both delegate & live but it didn’t work still.
function getAns(val) {
var value;
value = $("input[name=ans"+val+"]:checked").val();
$.post('ajax.php', {val:value}, function(data) {
alert(data);
});
//only works with this alert
alert('done');
});
}
Looks like you had an additional
});in your function. You are also usingvalas an object key when it holds a value from the function argument. Not sure if that was intentional, but try this: