Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing JS Array to java using jquery

 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here is my js function



while i look in the firebug, the contents of the array looks like this



but when the access the array in my action class i see this


What am i missing and where am i wrong ??


Cheers
n4v33n
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you inspected how the data is being passed in HTTP? Whenever you have this type of issue, the first thing to check is whether the data is being passed in the HTTP request as you expect.

Firebug is a good tool for this.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a note of adding things to an array

Instead of doing



you should use push



no need to use a counter!

Eric
 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tried push as well but it doesnt seem to work

what i guess from this is that , data: {array:sectionWeightsArrayObject} in mt js function probably doesnt accept object and we need to stringify that

am i right ??

if yes how would i achieve that
 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yo yo yo eric

i fixed this issue

i just had to do this

Cheers
n4v33n
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic