Last active
August 29, 2015 14:07
-
-
Save joasgarcia/d7b477d9cfb0a2fe330f to your computer and use it in GitHub Desktop.
Uma forma de enviar para o server um JSON com os dados de um form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formFilterReference = $("form") | |
var jsonString = convertFormToJSON(formFilterReference) | |
$("#otherForm #filterData").val(jsonString); | |
$("#otherForm").submit(); | |
var convertFormToJSON = function(form){ | |
var array = $(form).serializeArray(); | |
var json = {}; | |
$.each(array, function() { | |
json[this.name] = this.value || ""; | |
}); | |
return JSON.stringify(json); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment