View values of FormData

1

How can I print with console.log the values I capture in a FormData before sending it to a service by URL? .

I was trying this way:

e.preventDefault();
var form = $('#frmSede')[0];
var formdata = new FormData(form);
var oEstado = new FormData(document.forms.namedItem("estado"));
console.log("El estado es: " + oEstado);

And the deveploment tools console throws me this: The status is:

[object FormData]

I need to know what values I need to add a logic before passing it to my service.

    
asked by Julio Mejia 16.12.2017 в 05:51
source

1 answer

1

You can use JSON.stringify() , which converts an object of javascript to a string JSON .

Example:

var objeto = { un_dato_importante: '¡Felices fiestas a todos!' };

console.log( 'A pelo: ' + objeto );
console.log( 'Con JSON.stringify: ' + JSON.stringify( objeto ) );

You can also use in your case FormData.get

Example:

var form = new FormData();
form.append('datos', 'si es un dato');
console.log( form.get('datos') );
    
answered by 16.12.2017 в 09:45