0

I'm trying to work on how to append some more values to the serialize method in JQuery.

snippet

// 
      var dataString = $("#myform").serialize();
        dataString.push({name:"type", value: "myvalue"});
//

On passing the values to ajax call page

I am using this additional data for my conditional check as

if ( $_POST['type'] == 'myvalue')
 {
  // on success code 
  }
else
{
   //On fail Code
 }

But the condition is always going to else but now in if condition, Please assist If I am missing something and taking it wrong.

**NOTE the code is working fine if I am passing this name and value as hidden field form form ...

Mr AJ
  • 1,567
  • 3
  • 26
  • 49

1 Answers1

1

Use .serializeArray()

var dataString = $("#myform").serializeArray();
dataString.push({
    name: "type",
    value: "myvalue"
});
Arun P Johny
  • 376,738
  • 64
  • 519
  • 520