I'm trying to use jquery to capture a form and remove in the form all the disabled / readonly properties that contain the inputs and select boxes, without affecting the user's view, I've tried with two versions, but I did not none works and affect the user's (html) view, also try changing the .each () to .find ():
var $form = $("#formarea");
var $form = $form.each('input').prop('readonly', false);
var $form = $form.each('select').prop('disabled', false);
And save it in an object to be sent with ajax including the input and select box that are disabled or readonly:
var formData = new FormData();
var params = $form.serializeArray();
$.ajax({
url: $form.attr('action'),
data: formData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
error: function(xhr,status,error){console.log('Error')},
success: function(response) {console.log('Logrado')}
});
I'm getting the following error:
jquery.min.js:2 Uncaught TypeError: b.call is not a function
at Function.each (jquery.min.js:2)
at jQuery.fn.init.each (jquery.min.js:2)
at HTMLButtonElement.<anonymous> (ajax.event.js:263)
at HTMLFormElement.dispatch (jquery.min.js:3)
at HTMLFormElement.q.handle (jquery.min.js:3)
each @ jquery.min.js:2
each @ jquery.min.js:2
(anonymous) @ ajax.event.js:263
dispatch @ jquery.min.js:3
q.handle @ jquery.min.js:3
this line:
at HTMLButtonElement.<anonymous> (ajax.event.js:263)
refer to this:
var $form = $form.each('select').prop('disabled', false);
How do I fix it?