[jQuery] Re: post an array

2009-09-09 Thread Adonis

Hello,

I managed to post my array by calling toString() javascript method :

$.ajax({
type: "POST",
url: "/addFeature/",
data: {project_name:project_name,
'vertexArray':vertexArray.toString()},
success: function(msg){
alert("done");
}
});

I dunno if this is proper or not but it works and that is fine for
now!
Thanks for the help.


On Sep 9, 2:08 pm, Alex Weber  wrote:
> You can'tposta javascript object, its gotta be key-value pairs
> if the data is coming from a form you can do:
>
> var serial = $('#myform').serialize();
>
> andpostthe variable serial
>
> if not then as far as I know you gotta convert the object into key-
> value pairs some other way!
>
> On Sep 9, 6:13 am, Adonis  wrote:
>
>
>
> > Hi,
>
> > I can not upload anarrayto the server...
>
> > I am using this:
>
> > $.post("/addPolyline/", {project_name:project_name,
> > polyline_coordinates:vertexArray}, function(data){
> > alert("Done");
>
> > });
>
> > project_name is a string.
> > The vertexArray contains coordinates so it could look like this:
> > [(-11.2323,34.3455),(12.2323,34.3455),(18.2323,-78.3455),
> > (13.2323,35.3455)]. The server side is fine because it works if i do
> > not send thearray.
>
> > I tried different syntax such as the site recommends(e.g
> > 'polyline_coordinates[]':vertexArray) but still it does not work...
>
> > Any ideas?- Hide quoted text -
>
> - Show quoted text -


[jQuery] Re: post an array

2009-09-09 Thread Alex Weber

You can't post a javascript object, its gotta be key-value pairs
if the data is coming from a form you can do:

var serial = $('#myform').serialize();

and post the variable serial

if not then as far as I know you gotta convert the object into key-
value pairs some other way!

On Sep 9, 6:13 am, Adonis  wrote:
> Hi,
>
> I can not upload an array to the server...
>
> I am using this:
>
> $.post("/addPolyline/", {project_name:project_name,
> polyline_coordinates:vertexArray}, function(data){
> alert("Done");
>
> });
>
> project_name is a string.
> The vertexArray contains coordinates so it could look like this:
> [(-11.2323,34.3455),(12.2323,34.3455),(18.2323,-78.3455),
> (13.2323,35.3455)]. The server side is fine because it works if i do
> not send the array.
>
> I tried different syntax such as the site recommends(e.g
> 'polyline_coordinates[]':vertexArray) but still it does not work...
>
> Any ideas?