var Dados = {};
Dados.email = jQuery("#email").val();
Dados.nome= jQuery("#nome").val();
var urlparams = Dados.serialize();
My console returns Data.serialize is not a function have any errors in the code?
var Dados = {};
Dados.email = jQuery("#email").val();
Dados.nome= jQuery("#nome").val();
var urlparams = Dados.serialize();
My console returns Data.serialize is not a function have any errors in the code?
You are using the wrong method. The .serialize()
method, according to the documentation, is used to create a string in the URL-encoded via a jQuery object that has selected form fields, such as input
s, select
and textarea
s, or the form itself.
What you are looking for is the $.param()
function, which creates a representation serialized from an object's data:
const string = $.param({
name: 'Luiz Felipe',
nickname: 'lffg'
});
console.log(string);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
jQuery.param
; .serialize()
(jQuery) .