Link to home
Create AccountLog in
Avatar of Pradip Shenolkar
Pradip ShenolkarFlag for India

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 :
<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 ";
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
				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;
	}"POST", "rrz_ajax.jsp", true);
Click on Send button.<br/>
<input type='button' onclick="ajaxFunction();" value="Send" /><br/>
Result from server: <input type='text' id='result' size="100"/>

Open in new window

The jsp page :
String product = request.getParameter("product");
String location = request.getParameter("location");
String year = request.getParameter("year");

Open in new window

Avatar of Pradip Shenolkar
Pradip Shenolkar
Flag of India image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account