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 X
  • 1,637
  • 3
  • 29
  • 55

1 Answers1

1

Use .serializeArray()

var dataString = $("#myform").serializeArray();
dataString.push({
    name: "type",
    value: "myvalue"
});
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531