I have a list of variables available to me and I want to send it via $.ajax post. What format would I have to keep these in to use the function .serialize? I keep getting this error:
Object 'blank' has no method 'serialize'
I've tried to make them an array and I've tried jQuery.param(). I have a feeling this is simple but I can't seem to get it. Thanks!
var $data = jQuery.makeArray(attachmentId = attachmentID, action = 'rename', oldName = filename, newName, bucketName, oldFolderName, newFolderName, projectId = PID, businessId = BID);
var serializedData = $data.serializeArray();
//alert(theurl);
$.ajax({ type: "post", url: theurl, data: serializedData, dataType: 'json', success: reCreateTree });
.serializeis for form fields. Just use an object as value of thedata:option.jQuery.makeArray(attachmentId = attachmentID, ...)is doing? This is not how JavaScript works..makeArrayexpects an object. Just have a look at the examples in the$.ajaxdocumentation, you will find, e.g.data: {id : menuId},. I recommend to read the MDN JavaScript Guide to learn the basics of the language..serializedocumentation says: "Encode a set of form elements as a string for submission.". And the$.ajaxdocumentation says for thedataoption: "Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below)." All the information you need is there ;)