arrays - How to change Jquery ajax get params to ajax post params, like '?name=2&name=3&name=4'? -


i wanna post lot of same field values server in jquery ajax, can via adding values url, wanna know how using data attribute. there must have equal way.

$.ajax({     type : "post",     url : 'abc.action?name=5&name=6',     data : {         name : 2,         name : 3     },     error : function() {         console.error("operate failed");     },     success : function(data) {         console.log(data);     } }); 

in above code, request send 5, 6 , 3 server, not 2. enter image description here

maybe problem different using different server side, use struts2.

you seem looking array.

just define variable name array. , push values it, , once has values send in ajax request.

name = [];  name.push("2"); name.push("3");  $.ajax({     type : "post",     url : 'abc.action',     data : {         name : name     },     error : function() { ..... 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -