Hi,

> If I understand you correctly, you are telling me to read 'value 1',
> 'value 2' etc from the text field and then build the object and pass
> is. Is that right?

Either that, or supply the parameters in query string format.

With what you're describing, I'd suggest either putting more structure
in place, or if you want a free-form field people type (or more likely
paste) into, define the format and then parse it.  name=value, one
entry per line is pretty common and _very_ easily parsed. :-)

One format you could use is JSON[1].  If you do that, you can use
Prototype's String#evalJSON[2] function to convert it into a POJO.  Be
sure to use the sanitize option, though, because Prototype uses eval()
behind the scenes to turn the JSON into an object, and malicious
script kiddies might try to have a go at you.  The nice thing about
parsing some other format yourself is that you have less of an issue
that way.

[1] http://json.org
[2] http://prototypejs.org/api/string/evalJSON

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Apr 23, 10:02 am, Arpan Dhandhania <arpa...@gmail.com> wrote:
> Hi T J,
>
> If I understand you correctly, you are telling me to read 'value 1',
> 'value 2' etc from the text field and then build the object and pass
> is. Is that right?
>
> Now the problem is that the parameters are not pre-determined. I am
> basically building an API and this form will work as a testing page
> for the API. The parameter list therefore will depend on the API end
> point. I would ideally like to enter the following in the text field:
>
>   param1: 'value 1',
>   param2: 'value 2'
>
> And then it should get sent as parameters correctly.
>
> Is there a way for me to do that?
>
> regards,
> Arpan D.
>
> On Apr 23, 12:58 pm, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
>
> > Hi Arpan,
>
> > Refer to the API docs page[1], if you're going to pass in a string, it
> > must be in query string format, e.g. "param1=value+1&param2=value+2".
> > Or if you prefer you can create a plain object from the data in your
> > text fields:
>
> > params = {
> >    param1: 'value 1',
> >    param2: 'value 2'
>
> > };
>
> > ...and pass that in, and Prototype will do the necessary escaping and
> > such.
>
> > [1]http://prototypejs.org/api/ajax/options
>
> > HTH,
> > --
> > T.J. Crowder
> > tj / crowder software / com
> > Independent Software Engineer, consulting services available
>
>
--~--~---------~--~----~------------~-------~--~----~
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 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to