开发者

jquery post function with array as parameter

i have to pass a array of values to a jsp page. i am using the following jquery function

$.post("add.jsp" ,{'URL_Arr': urlarray}, function (data) {   
    alert(urlarray);
    $('#einfo').html(data);
});

where, urlarray is an array.Alert shows me the (urlarray开发者_如何学编程)array values as 48,39,28

And add.jsp page conatains the following

String URL_Arr1=request.getParameter("URL_Arr");
out.println("arr:"+URL_Arr1);

Am getting the URL_Arr as null

Can any one help me in passing the array values to another jsp page using jquery post.


For arrays, jQuery will suffix the parameter name with [], so use URL_Arr[] as parameter name. You should also be using getParameterValues() to get all array values. The getParameter() would only return the first item.

Summarized:

String[] urlarray = request.getParameterValues("URL_Arr[]");
// ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜