Pergunta

How to strip all whitespaces (like spaces, tabs, newlines) from jQuery Ajax Data?

data: $('#field1, #field2, #field3').serialize()
Foi útil?

Solução

Try something like

var array = $('#field1, #field2, #field3').serializeArray();
$.each(array, function(i,o){
    o.value = o.value.replace(/\s/g, '');
})
....
data: array

Demo: Fiddle

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top