Pradip Shenolkar
asked on
How to pass javascript arrays to ajax send() method and retrieve them on jsp page ?
I have following html page:
Here I have passed url to ajax's send method and retrieved those values on jsp page.
How to pass multiple arrays instead of url to send() method, and how to retrieve those arrays on jsp ?
The code is from Expert rrz.
The html page :
The jsp page :
Here I have passed url to ajax's send method and retrieved those values on jsp page.
How to pass multiple arrays instead of url to send() method, and how to retrieve those arrays on jsp ?
The code is from Expert rrz.
The html page :
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<script type="text/javascript">
function ajaxFunction(){
var ajaxRequest;
var parameters="product=Mobile&location=India&year=2014 ";
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
alert("Error!!");
return false;
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
if (ajaxRequest.status === 200) {
} else {
alert('Error: ' + ajaxRequest.status);
}
//document.myForm.result.value = ajaxRequest.responseText;
document.getElementById("result").value = ajaxRequest.responseText;
}
}
ajaxRequest.open("POST", "rrz_ajax.jsp", true);
ajaxRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
ajaxRequest.send(parameters);
}
</script>
</head>
<body>
Click on Send button.<br/>
<input type='button' onclick="ajaxFunction();" value="Send" /><br/>
Result from server: <input type='text' id='result' size="100"/>
</body>
</html>
The jsp page :
<%
String product = request.getParameter("product");
String location = request.getParameter("location");
String year = request.getParameter("year");
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.