Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
Passing JS Array to java using jquery
Naveen puttu
Ranch Hand
Posts: 88
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
Here is my js function
function updateSectionWeights(){ var sectionWeightsArrayObject = new Array(); var count = 0; $("input[id^=section_]").each(function(){ var sectionId = $(this).attr('id').split("_")[1]; var sectionScore = $(this).val(); sectionWeightsArrayObject[count] = sectionId+"_"+sectionScore; count++; } ); $.ajax({ method : "PUT", url : 'addQuestionnaireWeights.do?§ionOrQuestion=sections&eventId='+<%=request.getParameter("eventId")%>, data: {array:sectionWeightsArrayObject}, beforeSend : function(){ $("input[id='forTogglingRfx']:hidden").val("collapsed"); $("div#toggleStyleForRfx").removeClass().addClass("sprite iconExpand"); $("div#aboutthisrfx").toggle(); } , // show loading just when link is clicked complete : function(){ } , // stop showing loading when the process is complete success : function(xml){ } }); }
while i look in the firebug, the contents of the array looks like this
sectionWeightsArrayObject["487897114_50.0", "487897117_50.0"]
but when the access the array in my action class i see this
["487897114_50.0"]
What am i missing and where am i wrong ??
Cheers
n4v33n
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Eric Pascarello
author
Posts: 15385
6
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Just a note of adding things to an array
Instead of doing
sectionWeightsArrayObject[count] = sectionId+"_"+sectionScore;
you should
use
push
sectionWeightsArrayObject.push(sectionId+"_"+sectionScore);
no need to use a counter!
Eric
Naveen puttu
Ranch Hand
Posts: 88
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
yo yo yo eric
i fixed this issue
i just had to do this
data: {array:sectionWeightsArrayObject.toString()}
Cheers
n4v33n
Yeah, but is it art? What do you think tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
dynamic table creation problem calling onchange
Absolute set Div with z-index Problem
Is there something better then event.pageX/Y?
about checking values between rows with dynamic table created using java script
Weird issue while populating a table using jquery
More...