1. 程式人生 > >jquery將form表單內容轉換為json字串

jquery將form表單內容轉換為json字串

 

var formObject = {};
var formArray = $("#form").serializeArray();
$.each(formArray, function (i, item) {
    formObject[item.name] = item.value;
});
var formJson = JSON.stringify(formObject);

 

參考url: https://blog.csdn.net/xiao_yu_gan/article/details/74504969