I have an AJAX request in a JSP which has other nested AJAX requests.
AJAX bit:
var boxval = new Array();
boxval = getcheckval();
for (var i = 0; i < boxval.length; i++) {
$.ajax({
type: "get",
url: "myservlet",
beforeSend: function() {
$('#text1')
.css({
"color": "red"
});
$('#text1')
.text(
"Running Graph");
},
data: {
"boxval": boxval[i]
},
success: function(
responseText) {
$('#text1')
.css({
"color": "green"
});
$('#text1')
.text(
responseText);
},
complete: function() {
$.ajax({
type: "get",
url: "ConnectServlet",
beforeSend: function() {
$('#text2')
.css({
"color": "red"
});
$('#text2')
.text(
"Copying Files and preparing pSet");
},
data: {
val: boxval[i]
},
success: function(
responseText) {
$('#text2')
.css({
"color": "green"
});
$(
'#text2')
.text(
responseText);
},
complete: function() {
$.ajax({
type: "get",
url: "CopyServlet",
beforeSend: function() {
$('#text3')
.css({
"color": "red"
});
$('#text3')
.text(
"Running Dynamic Diff Graph");
},
data: {
box: boxval[i]
},
success: function(
responseText) {
$('#text3')
.css({
"color": "green"
});
$('#text3')
.text(
responseText);
},
complete: function() {
$('#summary')
.show();
}
});
}
});
}
});
}
In my first AJAX request the servlet is able to receive the data I am sending as a parameter:
data : {
"boxval" : boxval[i]
},
String graphName=request.getParameter("boxval");
However in all my nested ajax requests the servlet is unable to receive the data I am sending as a parameter:
data : {
"val" : boxval[i]
},
String graphName=request.getParameter("val");
The parameter returns null.
Why is this happening? What am I doing wrong?