I'm trying to return more than one value to jqueryAjax success but failed to do so. this what I have done so far......
String emp = request.getParameter("ID");
ArrayList<String> al = new ArrayList();
al=ur.editLeave(emp);
String cl = al.get(0);
out.print(cl);
out.print(al.get(1));
out.print(al.get(2));
from this jsp page I try to return 3 values.
$.ajax({
type: "GET",
data: 'ID=' + idel,
async: false,
url: "ForleaveMaster.jsp?Eleave=l",
success: function(cl, ml, ot) {
alert(cl, ml, ot);
$('input[id=ELM_CL]').val($.trim(cl));
$('input[id=ELM_ML]').val($.trim(cl));
$('input[id=ELM_OT]').val($.trim(cl));
},
error: function() {}
});
Please help me out.
Everything you return is passed as a first argument to your function.
$.ajax({
type: "GET",
data: 'ID=' + idel,
async: false,
url: "ForleaveMaster.jsp?Eleave=l",
success: function(data) {
var array_data = String(data).split("\n");
var cl = array_data[0],
mt = array_data[1],
ot = array_data[2];
alert(cl,ml,ot);
$('input[id=ELM_CL]').val($.trim(cl));
$('input[id=ELM_ML]').val($.trim(cl));
$('input[id=ELM_OT]').val($.trim(cl));
},
error: function() {
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With