ElkunCoding

how to log form data in jquery

To log the values of a FormData object in jQuery, you can iterate through the object using the forEach method and print the values to the console. Here’s an example:

var formData = new FormData(); 
  formData.append('key1', 'value1'); 
  formData.append('key2', 'value2'); 
  formData.forEach(function(value, key) { 
  console.log(key + ': ' + value); }
);

This will output the following to the console:

key1: value1 key2: value2

You can also use the get method to retrieve the value of a specific key in the FormData object:

console.log(formData.get('key1')); // Outputs "value1"

Leave a Comment

Your email address will not be published. Required fields are marked *