var sample=[]; sample.push("one"); sample.push("two"); sample.push("three"); $.ajax({ url : 'sampleAction', dataType : 'json', type : 'POST', data : { 'message':sample }, success:function(data){ } }); - This array symbol suggests the key of that array. Like one is on 0th (first) key and so on.Mohit Tanwani– Mohit Tanwani2016-07-28 05:21:37 +00:00Commented Jul 28, 2016 at 5:21
- Why you want to remove that symbol?Mayank Pandeyz– Mayank Pandeyz2016-07-28 05:23:47 +00:00Commented Jul 28, 2016 at 5:23
- in server side I get this parameter as arraylist...hardcode– hardcode2016-07-28 05:26:09 +00:00Commented Jul 28, 2016 at 5:26
Add a comment |
2 Answers
Here you are passing data as array, then it should pass with array symbol. For avoid array symbol you have to pass associative object without nested with message key. And in your server side script you need to change accordingly for grab posted data.
var sample=(); sample.one = "one"; sample.two = "two"; sample.three = "three"; $.ajax({ url : 'sampleAction', dataType : 'json', type : 'POST', data : sample, success:function(data){ } }); If you pass multiple messages then I am advising you to keep in array format because it is very easy to access it in server side.
1 Comment
hardcode
yes i am sending multiple message, but in server side I get that as array lis, not array so I have to avoid [] symbol, previously I tried the same thing that time the parameter send without [] symbol...

