jQuery: Change value in serialized form: Rails Change request method before sending data

/**
 * Change the request method from serialized form to 'get'
 * @param form Serialized form object
 * @returns {Serialized form}
 */
function changeRequestMethod(form) {
 // Keeping track from where this request is generated
 form.push({name: 'reqFrom', value: 'verify'});
 $.each(form, function (i, field) {
   if (field.name == '_method') {
   field.value = 'get';
   return form;
   }
 });
 return form;
}

var formData = $('.bid-form').serializeArray();
formData = changeRequestMethod(formData);

What does enctype=’multipart/form-data’ mean in a form

HTML forms provide three methods of encoding.

  • application/x-www-form-urlencoded (the default)
  • multipart/form-data
  • text/plain

The specifics of the formats don’t matter to most developers. The important points are:

When you are writing client-side code, all you need to know is use multipart/form-data when your form includes any <input type="file"> elements.

When you are writing server-side code: Use a prewritten form handling library (e.g. Perl’s CGI->paramor the one exposed by PHP’s $_POST superglobal) and it will take care of the differences for you. Don’t bother trying to parse the raw input received by the server.