Kim,

Your attempt using "formData[2].value = blah" should work.

Consider the following form:

<form action="#">
   <input type="text" name="user" />
   <input type="password" name="pwd" />
   <input type="submit" />
</form>

This code placed in a doc-ready block shows how to modify the data
before it is sent:

$('form').ajaxForm( {
   beforeSubmit: function(data, $form, opts) {
       // data is an array that looks like this:
       //
       // [
       //    { name: 'user', value: 'value entered' },
       //    { name: 'pwd',  value: 'value entered' }
       // ]

       alert('password entered: ' + data[1].value);
       data[1].value = "Kim";
       alert('modified password: ' + data[1].value);
   }
} );

Try this code and watch the XHR request in Firebug.  You'll see that
the password value is submitted as "Kim".

Mike



On 4/4/07, Kim Johnson <[EMAIL PROTECTED]> wrote:

Thanks Mike!

What is the best way to change the data? I tried a
number of things including accessing formData with
array notation (formData[2].value = str_md5(tmp)
(where tmp is a copy of formData[2].value), direct
access (formData["password"]), and also I tried, just
in case, using it like a jquery object in various
ways. I tried this with jqForm as well.

In all of these cases when I then immediately alerted
formData[2], the original value was the one outputted,
not the changed version.

thanks :)
-kim
--- Mike Alsup <[EMAIL PROTECTED]> wrote:

>
> Kim,
>
> Your beforeSubmit handler is passed a reference to
> the form data in
> array format.  The array contains the data that will
> be serialized but
> you can modify its contents any way you wish within
> that handler.
>
> Mike
>
> > I have a password field that I'd like to encrypt
> > before sending via ajaxSubmit (a simple MD5 call
> would
> > suffice). I know I can use beforeSubmit to do
> things,
> > but am not sure how to physically change a value.
> I've
> > attempted various things with jqForm and formData
> to
> > no avail -- is it a correct assumption that
> there's no
> > way to have the beforeSubmit function be call by
> > reference?
>




____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

Reply via email to