[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Alex Mcauley

basically i think i need a push method to push values into a json object

then i can try to decode it on the server!!

- Original Message - 
From: Jeztah [EMAIL PROTECTED]
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Monday, November 17, 2008 11:51 AM
Subject: [Proto-Scripty] Sending Json to the server



 Morning Guys ...

 I am having a real headache trying to send json data to the server and
 have php decode it so i can do something with the data ..
 .
 Basically what i am trying to do is...

 I have a form and i would like to send data to the server in Json form
 (key/value pairs) so i can go over it in a loop with php cehcking
 somehting against a database...

 I did think of serialize() but i need to send information in a custom
 tag thats in some input values somethin like

 input type=text id=foo_12323142341234 class=formJson
 dbCol=forename value=John /
 input type=text id=foo_12323142344321 class=formJson
 dbCol=surname value=Doe /
 and have in the json
 var params=new Array();
 $$('.formJson').each(function(e) {
 var p=$(e).dbCol + $(e).value;
 var d=p.toJSON();
 params.push(d);
 }
 to end up with something like .
 forename : John,
 surname : Doe

 toJSON() seems to not be playing nice and tells me its not a function

 Can anyone think of a way to encode all the elements with the
 className of 'formJson' grabbing the custom tag (dbCol) and the value
 of the element into an object or an array and send it to the server
 (running php 5.2) so i can process it on the server end ..

 I've been scratching my head over it all morning and cant find a
 solution !!

 Regards
 Alex
 
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Alex Mcauley

cant use it as it needs to be custom as stipulated ... i need to get certain 
fields from the input elements ..

merge() seems to want to do it but is not working as expected

Thanks
Alex

- Original Message - 
From: Mona Remlawi [EMAIL PROTECTED]
To: prototype-scriptaculous@googlegroups.com
Sent: Monday, November 17, 2008 12:34 PM
Subject: [Proto-Scripty] Re: Sending Json to the server



 hmm just out of the top of my head here, did you try using
 $H(form.serialiaze()) ?

 cheers

 --
 mona
 [EMAIL PROTECTED]

 On Mon, Nov 17, 2008 at 1:13 PM, Alex Mcauley
 [EMAIL PROTECTED] wrote:

 basically i think i need a push method to push values into a json object

 then i can try to decode it on the server!!

 - Original Message -
 From: Jeztah [EMAIL PROTECTED]
 To: Prototype  script.aculo.us 
 prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 11:51 AM
 Subject: [Proto-Scripty] Sending Json to the server



 Morning Guys ...

 I am having a real headache trying to send json data to the server and
 have php decode it so i can do something with the data ..
 .
 Basically what i am trying to do is...

 I have a form and i would like to send data to the server in Json form
 (key/value pairs) so i can go over it in a loop with php cehcking
 somehting against a database...

 I did think of serialize() but i need to send information in a custom
 tag thats in some input values somethin like

 input type=text id=foo_12323142341234 class=formJson
 dbCol=forename value=John /
 input type=text id=foo_12323142344321 class=formJson
 dbCol=surname value=Doe /
 and have in the json
 var params=new Array();
 $$('.formJson').each(function(e) {
 var p=$(e).dbCol + $(e).value;
 var d=p.toJSON();
 params.push(d);
 }
 to end up with something like .
 forename : John,
 surname : Doe

 toJSON() seems to not be playing nice and tells me its not a function

 Can anyone think of a way to encode all the elements with the
 className of 'formJson' grabbing the custom tag (dbCol) and the value
 of the element into an object or an array and send it to the server
 (running php 5.2) so i can process it on the server end ..

 I've been scratching my head over it all morning and cant find a
 solution !!

 Regards
 Alex
 



 


 
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Mona Remlawi

ok what about this:

var params = {};
$$('.formJson').each(function(e) {
  params[$(e).dbCol] = $(e).value;
}

cheers

--
mona
[EMAIL PROTECTED]

On Mon, Nov 17, 2008 at 1:43 PM, Alex Mcauley
[EMAIL PROTECTED] wrote:

 cant use it as it needs to be custom as stipulated ... i need to get certain
 fields from the input elements ..

 merge() seems to want to do it but is not working as expected

 Thanks
 Alex

 - Original Message -
 From: Mona Remlawi [EMAIL PROTECTED]
 To: prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 12:34 PM
 Subject: [Proto-Scripty] Re: Sending Json to the server



 hmm just out of the top of my head here, did you try using
 $H(form.serialiaze()) ?

 cheers

 --
 mona
 [EMAIL PROTECTED]

 On Mon, Nov 17, 2008 at 1:13 PM, Alex Mcauley
 [EMAIL PROTECTED] wrote:

 basically i think i need a push method to push values into a json object

 then i can try to decode it on the server!!

 - Original Message -
 From: Jeztah [EMAIL PROTECTED]
 To: Prototype  script.aculo.us
 prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 11:51 AM
 Subject: [Proto-Scripty] Sending Json to the server



 Morning Guys ...

 I am having a real headache trying to send json data to the server and
 have php decode it so i can do something with the data ..
 .
 Basically what i am trying to do is...

 I have a form and i would like to send data to the server in Json form
 (key/value pairs) so i can go over it in a loop with php cehcking
 somehting against a database...

 I did think of serialize() but i need to send information in a custom
 tag thats in some input values somethin like

 input type=text id=foo_12323142341234 class=formJson
 dbCol=forename value=John /
 input type=text id=foo_12323142344321 class=formJson
 dbCol=surname value=Doe /
 and have in the json
 var params=new Array();
 $$('.formJson').each(function(e) {
 var p=$(e).dbCol + $(e).value;
 var d=p.toJSON();
 params.push(d);
 }
 to end up with something like .
 forename : John,
 surname : Doe

 toJSON() seems to not be playing nice and tells me its not a function

 Can anyone think of a way to encode all the elements with the
 className of 'formJson' grabbing the custom tag (dbCol) and the value
 of the element into an object or an array and send it to the server
 (running php 5.2) so i can process it on the server end ..

 I've been scratching my head over it all morning and cant find a
 solution !!

 Regards
 Alex
 



 


 



 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Alex Mcauley

can i send all that into json afterwards to send it to the server ?


Thanks
Alex
- Original Message - 
From: Mona Remlawi [EMAIL PROTECTED]
To: prototype-scriptaculous@googlegroups.com
Sent: Monday, November 17, 2008 12:52 PM
Subject: [Proto-Scripty] Re: Sending Json to the server



 ok what about this:

 var params = {};
 $$('.formJson').each(function(e) {
  params[$(e).dbCol] = $(e).value;
 }

 cheers

 --
 mona
 [EMAIL PROTECTED]

 On Mon, Nov 17, 2008 at 1:43 PM, Alex Mcauley
 [EMAIL PROTECTED] wrote:

 cant use it as it needs to be custom as stipulated ... i need to get 
 certain
 fields from the input elements ..

 merge() seems to want to do it but is not working as expected

 Thanks
 Alex

 - Original Message -
 From: Mona Remlawi [EMAIL PROTECTED]
 To: prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 12:34 PM
 Subject: [Proto-Scripty] Re: Sending Json to the server



 hmm just out of the top of my head here, did you try using
 $H(form.serialiaze()) ?

 cheers

 --
 mona
 [EMAIL PROTECTED]

 On Mon, Nov 17, 2008 at 1:13 PM, Alex Mcauley
 [EMAIL PROTECTED] wrote:

 basically i think i need a push method to push values into a json 
 object

 then i can try to decode it on the server!!

 - Original Message -
 From: Jeztah [EMAIL PROTECTED]
 To: Prototype  script.aculo.us
 prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 11:51 AM
 Subject: [Proto-Scripty] Sending Json to the server



 Morning Guys ...

 I am having a real headache trying to send json data to the server and
 have php decode it so i can do something with the data ..
 .
 Basically what i am trying to do is...

 I have a form and i would like to send data to the server in Json form
 (key/value pairs) so i can go over it in a loop with php cehcking
 somehting against a database...

 I did think of serialize() but i need to send information in a custom
 tag thats in some input values somethin like

 input type=text id=foo_12323142341234 class=formJson
 dbCol=forename value=John /
 input type=text id=foo_12323142344321 class=formJson
 dbCol=surname value=Doe /
 and have in the json
 var params=new Array();
 $$('.formJson').each(function(e) {
 var p=$(e).dbCol + $(e).value;
 var d=p.toJSON();
 params.push(d);
 }
 to end up with something like .
 forename : John,
 surname : Doe

 toJSON() seems to not be playing nice and tells me its not a function

 Can anyone think of a way to encode all the elements with the
 className of 'formJson' grabbing the custom tag (dbCol) and the value
 of the element into an object or an array and send it to the server
 (running php 5.2) so i can process it on the server end ..

 I've been scratching my head over it all morning and cant find a
 solution !!

 Regards
 Alex
 



 


 



 


 
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Mona Remlawi

here's what i will do to send the json to server
---
new Ajax.Request(url, {
   postBody: Object.toJSON(params),
   contentType: text/javascript,
   onSuccess: function(xhr) {
   },
   onFailure: function(xhr) {
   },
   onComplete: function(xhr) {
   }
});
---

another thing, you can lose those redundant $(e) in the array iterator.


cheers

--
mona
[EMAIL PROTECTED]

On Mon, Nov 17, 2008 at 1:53 PM, Alex Mcauley
[EMAIL PROTECTED] wrote:

 can i send all that into json afterwards to send it to the server ?


 Thanks
 Alex
 - Original Message -
 From: Mona Remlawi [EMAIL PROTECTED]
 To: prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 12:52 PM
 Subject: [Proto-Scripty] Re: Sending Json to the server



 ok what about this:

 var params = {};
 $$('.formJson').each(function(e) {
  params[$(e).dbCol] = $(e).value;
 }

 cheers

 --
 mona
 [EMAIL PROTECTED]

 On Mon, Nov 17, 2008 at 1:43 PM, Alex Mcauley
 [EMAIL PROTECTED] wrote:

 cant use it as it needs to be custom as stipulated ... i need to get
 certain
 fields from the input elements ..

 merge() seems to want to do it but is not working as expected

 Thanks
 Alex

 - Original Message -
 From: Mona Remlawi [EMAIL PROTECTED]
 To: prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 12:34 PM
 Subject: [Proto-Scripty] Re: Sending Json to the server



 hmm just out of the top of my head here, did you try using
 $H(form.serialiaze()) ?

 cheers

 --
 mona
 [EMAIL PROTECTED]

 On Mon, Nov 17, 2008 at 1:13 PM, Alex Mcauley
 [EMAIL PROTECTED] wrote:

 basically i think i need a push method to push values into a json
 object

 then i can try to decode it on the server!!

 - Original Message -
 From: Jeztah [EMAIL PROTECTED]
 To: Prototype  script.aculo.us
 prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 11:51 AM
 Subject: [Proto-Scripty] Sending Json to the server



 Morning Guys ...

 I am having a real headache trying to send json data to the server and
 have php decode it so i can do something with the data ..
 .
 Basically what i am trying to do is...

 I have a form and i would like to send data to the server in Json form
 (key/value pairs) so i can go over it in a loop with php cehcking
 somehting against a database...

 I did think of serialize() but i need to send information in a custom
 tag thats in some input values somethin like

 input type=text id=foo_12323142341234 class=formJson
 dbCol=forename value=John /
 input type=text id=foo_12323142344321 class=formJson
 dbCol=surname value=Doe /
 and have in the json
 var params=new Array();
 $$('.formJson').each(function(e) {
 var p=$(e).dbCol + $(e).value;
 var d=p.toJSON();
 params.push(d);
 }
 to end up with something like .
 forename : John,
 surname : Doe

 toJSON() seems to not be playing nice and tells me its not a function

 Can anyone think of a way to encode all the elements with the
 className of 'formJson' grabbing the custom tag (dbCol) and the value
 of the element into an object or an array and send it to the server
 (running php 5.2) so i can process it on the server end ..

 I've been scratching my head over it all morning and cant find a
 solution !!

 Regards
 Alex
 



 


 



 


 



 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Alex Mcauley

I  suppose what i need is a push into my json object method ... though i 
cant seem to find a working one in prototypejs ..

merge(); and update(); both seem to want to be used with $H() but it updates 
with my var ...

Something like {l : doe}

when it should be {surname : doe};

plus it doesnt merge each of them !! it only merges the last one !!

Regards
Alex



- Original Message - 
From: T.J. Crowder [EMAIL PROTECTED]
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Monday, November 17, 2008 1:05 PM
Subject: [Proto-Scripty] Re: Sending Json to the server



Alex,

Why send it to the server in JSON format as opposed to standard POST
encoding?  If all you want is key/value pairs, just sending POST data
seems much more straight-forward.

Separately, on the code:

 $$('.formJson').each(function(e) {
 var p=$(e).dbCol + $(e).value;
 var d=p.toJSON();
 params.push(d);}

$$ returns extended elements[1], so no need to extend them again (much
less repeatedly).  Also, when creating 'p', you're not putting any
kind of delimiter between the dbCol property and the value, so you'll
get a string like surnameDoe.  Also, you're expecting to be able to
access an attribute of an element ('dbCol') as thought it were a
property of the Element object; you can't.  You can get it via
Prototype's readAttribute method[2], though.

[1] http://www.prototypejs.org/api/utility/dollar-dollar
[2] http://www.prototypejs.org/api/element/readAttribute
--
T.J. Crowder
tj / crowder software / com

On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote:
 Morning Guys ...

 I am having a real headache trying to send json data to the server and
 have php decode it so i can do something with the data ..
 .
 Basically what i am trying to do is...

 I have a form and i would like to send data to the server in Json form
 (key/value pairs) so i can go over it in a loop with php cehcking
 somehting against a database...

 I did think of serialize() but i need to send information in a custom
 tag thats in some input values somethin like

 input type=text id=foo_12323142341234 class=formJson
 dbCol=forename value=John /
 input type=text id=foo_12323142344321 class=formJson
 dbCol=surname value=Doe /
 and have in the json
 var params=new Array();
 $$('.formJson').each(function(e) {
 var p=$(e).dbCol + $(e).value;
 var d=p.toJSON();
 params.push(d);}

 to end up with something like .
 forename : John,
 surname : Doe

 toJSON() seems to not be playing nice and tells me its not a function

 Can anyone think of a way to encode all the elements with the
 className of 'formJson' grabbing the custom tag (dbCol) and the value
 of the element into an object or an array and send it to the server
 (running php 5.2) so i can process it on the server end ..

 I've been scratching my head over it all morning and cant find a
 solution !!

 Regards
 Alex



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread T.J. Crowder

 Also the code you quote me on was psuedo code just to try to give an idea of
 what i am trying to achieve - i know it was unworking !

Alex, you've said that several times now.  If you post code that's not
code, please say it's not code to avoid wasting people's time.
Looking at:

var p=$(e).dbCol + $(e).value;

...it's not at all clear that's not meant to be code.  Not *good*
code, but I've seen worse. ;-)

Thanks,

-- T.J.

On Nov 17, 1:11 pm, Alex Mcauley [EMAIL PROTECTED]
wrote:
 because i need to evaluate each one and i need to send other post data that
 does not need evaluating .. the other post data is not allways static so i
 cant put if/else clauses on my serverside code to accomidate it ... what i
 need is the data from the each loop send as 1 post parameter and my other
 data sent as other parameters..

 I've been looking at toJSON() on the array created with the method supplied
 to me earlier ..

 Also the code you quote me on was psuedo code just to try to give an idea of
 what i am trying to achieve - i know it was unworking !

 Thanks
 Alex

 - Original Message -
 From: T.J. Crowder [EMAIL PROTECTED]
 To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 1:05 PM
 Subject: [Proto-Scripty] Re: Sending Json to the server

 Alex,

 Why send it to the server in JSON format as opposed to standard POST
 encoding?  If all you want is key/value pairs, just sending POST data
 seems much more straight-forward.

 Separately, on the code:

  $$('.formJson').each(function(e) {
  var p=$(e).dbCol + $(e).value;
  var d=p.toJSON();
  params.push(d);}

 $$ returns extended elements[1], so no need to extend them again (much
 less repeatedly).  Also, when creating 'p', you're not putting any
 kind of delimiter between the dbCol property and the value, so you'll
 get a string like surnameDoe.  Also, you're expecting to be able to
 access an attribute of an element ('dbCol') as thought it were a
 property of the Element object; you can't.  You can get it via
 Prototype's readAttribute method[2], though.

 [1]http://www.prototypejs.org/api/utility/dollar-dollar
 [2]http://www.prototypejs.org/api/element/readAttribute
 --
 T.J. Crowder
 tj / crowder software / com

 On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote:
  Morning Guys ...

  I am having a real headache trying to send json data to the server and
  have php decode it so i can do something with the data ..
  .
  Basically what i am trying to do is...

  I have a form and i would like to send data to the server in Json form
  (key/value pairs) so i can go over it in a loop with php cehcking
  somehting against a database...

  I did think of serialize() but i need to send information in a custom
  tag thats in some input values somethin like

  input type=text id=foo_12323142341234 class=formJson
  dbCol=forename value=John /
  input type=text id=foo_12323142344321 class=formJson
  dbCol=surname value=Doe /
  and have in the json
  var params=new Array();
  $$('.formJson').each(function(e) {
  var p=$(e).dbCol + $(e).value;
  var d=p.toJSON();
  params.push(d);}

  to end up with something like .
  forename : John,
  surname : Doe

  toJSON() seems to not be playing nice and tells me its not a function

  Can anyone think of a way to encode all the elements with the
  className of 'formJson' grabbing the custom tag (dbCol) and the value
  of the element into an object or an array and send it to the server
  (running php 5.2) so i can process it on the server end ..

  I've been scratching my head over it all morning and cant find a
  solution !!

  Regards
  Alex


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Alex Mcauley

okay m8 calm down lol its no biggie ..

- Original Message - 
From: T.J. Crowder [EMAIL PROTECTED]
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Monday, November 17, 2008 2:01 PM
Subject: [Proto-Scripty] Re: Sending Json to the server



 Also the code you quote me on was psuedo code just to try to give an idea 
 of
 what i am trying to achieve - i know it was unworking !

Alex, you've said that several times now.  If you post code that's not
code, please say it's not code to avoid wasting people's time.
Looking at:

var p=$(e).dbCol + $(e).value;

...it's not at all clear that's not meant to be code.  Not *good*
code, but I've seen worse. ;-)

Thanks,

-- T.J.

On Nov 17, 1:11 pm, Alex Mcauley [EMAIL PROTECTED]
wrote:
 because i need to evaluate each one and i need to send other post data 
 that
 does not need evaluating .. the other post data is not allways static so i
 cant put if/else clauses on my serverside code to accomidate it ... what i
 need is the data from the each loop send as 1 post parameter and my other
 data sent as other parameters..

 I've been looking at toJSON() on the array created with the method 
 supplied
 to me earlier ..

 Also the code you quote me on was psuedo code just to try to give an idea 
 of
 what i am trying to achieve - i know it was unworking !

 Thanks
 Alex

 - Original Message -
 From: T.J. Crowder [EMAIL PROTECTED]
 To: Prototype  script.aculo.us 
 prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 1:05 PM
 Subject: [Proto-Scripty] Re: Sending Json to the server

 Alex,

 Why send it to the server in JSON format as opposed to standard POST
 encoding? If all you want is key/value pairs, just sending POST data
 seems much more straight-forward.

 Separately, on the code:

  $$('.formJson').each(function(e) {
  var p=$(e).dbCol + $(e).value;
  var d=p.toJSON();
  params.push(d);}

 $$ returns extended elements[1], so no need to extend them again (much
 less repeatedly). Also, when creating 'p', you're not putting any
 kind of delimiter between the dbCol property and the value, so you'll
 get a string like surnameDoe. Also, you're expecting to be able to
 access an attribute of an element ('dbCol') as thought it were a
 property of the Element object; you can't. You can get it via
 Prototype's readAttribute method[2], though.

 [1]http://www.prototypejs.org/api/utility/dollar-dollar
 [2]http://www.prototypejs.org/api/element/readAttribute
 --
 T.J. Crowder
 tj / crowder software / com

 On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote:
  Morning Guys ...

  I am having a real headache trying to send json data to the server and
  have php decode it so i can do something with the data ..
  .
  Basically what i am trying to do is...

  I have a form and i would like to send data to the server in Json form
  (key/value pairs) so i can go over it in a loop with php cehcking
  somehting against a database...

  I did think of serialize() but i need to send information in a custom
  tag thats in some input values somethin like

  input type=text id=foo_12323142341234 class=formJson
  dbCol=forename value=John /
  input type=text id=foo_12323142344321 class=formJson
  dbCol=surname value=Doe /
  and have in the json
  var params=new Array();
  $$('.formJson').each(function(e) {
  var p=$(e).dbCol + $(e).value;
  var d=p.toJSON();
  params.push(d);}

  to end up with something like .
  forename : John,
  surname : Doe

  toJSON() seems to not be playing nice and tells me its not a function

  Can anyone think of a way to encode all the elements with the
  className of 'formJson' grabbing the custom tag (dbCol) and the value
  of the element into an object or an array and send it to the server
  (running php 5.2) so i can process it on the server end ..

  I've been scratching my head over it all morning and cant find a
  solution !!

  Regards
  Alex





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Tobie Langel

Guys, please stay courteous (and that includes avoiding shorthand).
Thank you!

Tobie

On Nov 17, 3:33 pm, Alex Mcauley [EMAIL PROTECTED]
wrote:
 okay m8 calm down lol its no biggie ..

 - Original Message -
 From: T.J. Crowder [EMAIL PROTECTED]
 To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 2:01 PM
 Subject: [Proto-Scripty] Re: Sending Json to the server

  Also the code you quote me on was psuedo code just to try to give an idea
  of
  what i am trying to achieve - i know it was unworking !

 Alex, you've said that several times now.  If you post code that's not
 code, please say it's not code to avoid wasting people's time.
 Looking at:

     var p=$(e).dbCol + $(e).value;

 ...it's not at all clear that's not meant to be code.  Not *good*
 code, but I've seen worse. ;-)

 Thanks,

 -- T.J.

 On Nov 17, 1:11 pm, Alex Mcauley [EMAIL PROTECTED]
 wrote:

  because i need to evaluate each one and i need to send other post data
  that
  does not need evaluating .. the other post data is not allways static so i
  cant put if/else clauses on my serverside code to accomidate it ... what i
  need is the data from the each loop send as 1 post parameter and my other
  data sent as other parameters..

  I've been looking at toJSON() on the array created with the method
  supplied
  to me earlier ..

  Also the code you quote me on was psuedo code just to try to give an idea
  of
  what i am trying to achieve - i know it was unworking !

  Thanks
  Alex

  - Original Message -
  From: T.J. Crowder [EMAIL PROTECTED]
  To: Prototype  script.aculo.us
  prototype-scriptaculous@googlegroups.com
  Sent: Monday, November 17, 2008 1:05 PM
  Subject: [Proto-Scripty] Re: Sending Json to the server

  Alex,

  Why send it to the server in JSON format as opposed to standard POST
  encoding? If all you want is key/value pairs, just sending POST data
  seems much more straight-forward.

  Separately, on the code:

   $$('.formJson').each(function(e) {
   var p=$(e).dbCol + $(e).value;
   var d=p.toJSON();
   params.push(d);}

  $$ returns extended elements[1], so no need to extend them again (much
  less repeatedly). Also, when creating 'p', you're not putting any
  kind of delimiter between the dbCol property and the value, so you'll
  get a string like surnameDoe. Also, you're expecting to be able to
  access an attribute of an element ('dbCol') as thought it were a
  property of the Element object; you can't. You can get it via
  Prototype's readAttribute method[2], though.

  [1]http://www.prototypejs.org/api/utility/dollar-dollar
  [2]http://www.prototypejs.org/api/element/readAttribute
  --
  T.J. Crowder
  tj / crowder software / com

  On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote:
   Morning Guys ...

   I am having a real headache trying to send json data to the server and
   have php decode it so i can do something with the data ..
   .
   Basically what i am trying to do is...

   I have a form and i would like to send data to the server in Json form
   (key/value pairs) so i can go over it in a loop with php cehcking
   somehting against a database...

   I did think of serialize() but i need to send information in a custom
   tag thats in some input values somethin like

   input type=text id=foo_12323142341234 class=formJson
   dbCol=forename value=John /
   input type=text id=foo_12323142344321 class=formJson
   dbCol=surname value=Doe /
   and have in the json
   var params=new Array();
   $$('.formJson').each(function(e) {
   var p=$(e).dbCol + $(e).value;
   var d=p.toJSON();
   params.push(d);}

   to end up with something like .
   forename : John,
   surname : Doe

   toJSON() seems to not be playing nice and tells me its not a function

   Can anyone think of a way to encode all the elements with the
   className of 'formJson' grabbing the custom tag (dbCol) and the value
   of the element into an object or an array and send it to the server
   (running php 5.2) so i can process it on the server end ..

   I've been scratching my head over it all morning and cant find a
   solution !!

   Regards
   Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Sending Json to the server

2008-11-17 Thread Alex Mcauley

No problems here.


- Original Message - 
From: Tobie Langel [EMAIL PROTECTED]
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Monday, November 17, 2008 2:48 PM
Subject: [Proto-Scripty] Re: Sending Json to the server



Guys, please stay courteous (and that includes avoiding shorthand).
Thank you!

Tobie

On Nov 17, 3:33 pm, Alex Mcauley [EMAIL PROTECTED]
wrote:
 okay m8 calm down lol its no biggie ..

 - Original Message -
 From: T.J. Crowder [EMAIL PROTECTED]
 To: Prototype  script.aculo.us 
 prototype-scriptaculous@googlegroups.com
 Sent: Monday, November 17, 2008 2:01 PM
 Subject: [Proto-Scripty] Re: Sending Json to the server

  Also the code you quote me on was psuedo code just to try to give an 
  idea
  of
  what i am trying to achieve - i know it was unworking !

 Alex, you've said that several times now. If you post code that's not
 code, please say it's not code to avoid wasting people's time.
 Looking at:

 var p=$(e).dbCol + $(e).value;

 ...it's not at all clear that's not meant to be code. Not *good*
 code, but I've seen worse. ;-)

 Thanks,

 -- T.J.

 On Nov 17, 1:11 pm, Alex Mcauley [EMAIL PROTECTED]
 wrote:

  because i need to evaluate each one and i need to send other post data
  that
  does not need evaluating .. the other post data is not allways static so 
  i
  cant put if/else clauses on my serverside code to accomidate it ... what 
  i
  need is the data from the each loop send as 1 post parameter and my 
  other
  data sent as other parameters..

  I've been looking at toJSON() on the array created with the method
  supplied
  to me earlier ..

  Also the code you quote me on was psuedo code just to try to give an 
  idea
  of
  what i am trying to achieve - i know it was unworking !

  Thanks
  Alex

  - Original Message -
  From: T.J. Crowder [EMAIL PROTECTED]
  To: Prototype  script.aculo.us
  prototype-scriptaculous@googlegroups.com
  Sent: Monday, November 17, 2008 1:05 PM
  Subject: [Proto-Scripty] Re: Sending Json to the server

  Alex,

  Why send it to the server in JSON format as opposed to standard POST
  encoding? If all you want is key/value pairs, just sending POST data
  seems much more straight-forward.

  Separately, on the code:

   $$('.formJson').each(function(e) {
   var p=$(e).dbCol + $(e).value;
   var d=p.toJSON();
   params.push(d);}

  $$ returns extended elements[1], so no need to extend them again (much
  less repeatedly). Also, when creating 'p', you're not putting any
  kind of delimiter between the dbCol property and the value, so you'll
  get a string like surnameDoe. Also, you're expecting to be able to
  access an attribute of an element ('dbCol') as thought it were a
  property of the Element object; you can't. You can get it via
  Prototype's readAttribute method[2], though.

  [1]http://www.prototypejs.org/api/utility/dollar-dollar
  [2]http://www.prototypejs.org/api/element/readAttribute
  --
  T.J. Crowder
  tj / crowder software / com

  On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote:
   Morning Guys ...

   I am having a real headache trying to send json data to the server and
   have php decode it so i can do something with the data ..
   .
   Basically what i am trying to do is...

   I have a form and i would like to send data to the server in Json form
   (key/value pairs) so i can go over it in a loop with php cehcking
   somehting against a database...

   I did think of serialize() but i need to send information in a custom
   tag thats in some input values somethin like

   input type=text id=foo_12323142341234 class=formJson
   dbCol=forename value=John /
   input type=text id=foo_12323142344321 class=formJson
   dbCol=surname value=Doe /
   and have in the json
   var params=new Array();
   $$('.formJson').each(function(e) {
   var p=$(e).dbCol + $(e).value;
   var d=p.toJSON();
   params.push(d);}

   to end up with something like .
   forename : John,
   surname : Doe

   toJSON() seems to not be playing nice and tells me its not a function

   Can anyone think of a way to encode all the elements with the
   className of 'formJson' grabbing the custom tag (dbCol) and the value
   of the element into an object or an array and send it to the server
   (running php 5.2) so i can process it on the server end ..

   I've been scratching my head over it all morning and cant find a
   solution !!

   Regards
   Alex



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---