AJAX POST to send serialized and unserialzed data at the same time

I was wondering if it is possible to send a serialized form and non-serialized data in a $.ajax post. I realize I kind of dug myself into a hole otherwise. I am trying to add and update table rows. My PHP file is expecting first an 'add' or 'edit' to come in, then process serialized data.

PHP - there is one for add and edit

if(isset($_POST['func']))}
 if($_POST['func']=='add_table_name'){
  if(isset($_POST['... all of the form inputs ... ']).........

My jquery function

function tableAction(tableId, tableFunc, rowId, callback){  
  tableURL = "php/table_" + tableId + ".php";
  tableData = { func : tableFunc + '_' + tableId, rowId : rowId };

$.ajax({
    type: 'POST',
    url: tableURL,
    data: tableData,
    success: function (data) {
        if(data){;
            if (callback){      
                    callback(data);
            }else{
                return;
            }
        }
    }
});

I call it like

tableAction(tableId, 'add', rowId, function()....

As you can see there is currently nowhere to input the form data. I was wondering if it can be serialized and then added to the data, something like

var formData = $('form').serialize();
....
....
  data: tableData + formData,

Thanks!

Answers


To answer my own question, I used $.extend

var formData = $('form').serialize();

$.extend(tableData,formData);


Need Your Help

Sed, awk, Perl or other for de-interleaving text file

perl shell text sed awk

I would like a relatively compact command to perform line-by-line de-interleaving of a text file, i.e

Cocoa, output current App path

osx cocoa xcode4

I am working on OS X application. In the code, I would like to output a path of the current Mac OS App to a variable for future use. So later I could read the files in the same folder. Could anyon...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.