JJShell:

You can address both issues by using all inputs within a form

var values = {};

$("form").find("input:text").each(function(){
  values[$(this).attr("name")] = $(this).val();
});

Now values will have the following structure for your second example, which
PHP should automatically turn into an array within $_POST:

{
  "pagetitle[1]" : "test",
  "pagetitle[2]" : "some title",
  "pagetitle[3]" : "some other title"
}

- jake

On Dec 21, 2007 3:00 AM, jjshell <[EMAIL PROTECTED]> wrote:

>
> First of all, thanks for your time and answers. I really appreciate
> it. Having made a few tests, the $.ajax approach seems the one that
> fits the most my application.
>
> Just a few questions:
>
> 1.
> Can you avoid to explicitely name each field of your form?
> data: "test=" + $("input[name=test]").val(),
> What if a form is dynamically created server-side? Do you also have to
> dynamically create a line for jQuery?
>
> 2.
> How dows this approach reacts to array fields?
>
> <input type="text" name="pagetitle[1]" value="test" />
> <input type="text" name="pagetitle[2]" value="some title" />
> <input type="text" name="pagetitle[3]" value="some other title" />
>
> Thank you again for your time :)
>

Reply via email to