I want to pass in few string to servlet using AQuery, by calling for loop to pass each string to my servlet. Below is my code:
String str = "st1-st2-st3";
String delimiter = "-";
String[] temp;
temp = str.split(delimiter);
for(int i =0; i < temp.length ; i++){
System.out.println("temp[i]->"+temp[i]);
params.put("myValue", temp[i]);
aq.ajax(url, params, String.class, new AjaxCallback<String>() {
@Override
public void callback(String url, String html, AjaxStatus status) {
//prodStr = html;
//showList1(prodStr, sortingAsc);
System.out.println("Show return");
}
});
}
Servlet code
String myValue = request.getParameter("myValue");
System.out.println("Show myValue->"+myValue);
I want my result become:
temp[i]->st1
Show return
temp[i]->st2
Show return
temp[i]->st3
Show return
But my code run the result as:
temp[i]->st1
temp[i]->st2
temp[i]->st3
Show return
I want it to call three times to the servlet, instead of once. In my print out servlet code is always show the last string value st3, st1 and st2 is missing. Is this possible? Please help, thanks.