0

So I have this as my current data:

data: $(this).serialize()

How can I have that and add another one?

Like

data: {
    $(this).serialize(),
    test: 'hello'
}
Andrew
  • 7
  • 1
  • possible duplicate of [$(this).serialize() -- How to add a value?](http://stackoverflow.com/questions/6539502/this-serialize-how-to-add-a-value) – Sean Aug 12 '14 at 19:02
  • Please search SO before asking, ie. answer from question above http://stackoverflow.com/a/6539539/689579 - `data: $(this).serialize() + '&test=hello',` – Sean Aug 12 '14 at 19:03
  • Sean's link helped me out. Thanks. – Andrew Aug 12 '14 at 19:14

1 Answers1

0

More like this:

var serialized = $(this).serialize();

$.ajax({
    //...
    data: {
        serialized: serialized,
        text: 'hello'
    }
Malovich
  • 931
  • 1
  • 5
  • 15
  • It didn't work. I have a bunch of things I need to pass. For example $_POST['email'] doesn't work now or anything other than 'text.' – Andrew Aug 12 '14 at 18:58
  • You do need to specify the `type` as POST if you want to collect data in the post. `$.ajax()` defaults to `$_GET` as of jQuery ~1.8. – Malovich Aug 12 '14 at 19:01
  • Also, did you get `serialized` from the ajax call? – Malovich Aug 12 '14 at 19:04