我正在从表单中提交的数据中构建一个 JSON 数组,但是这个脚本正在破坏,无法弄清楚是什么原因造成的!
有任何想法吗?
查询:
var canvas = [];
var Submission = {};
var Answer = {};
$('.question-holder > input').each(function(){
answer = $(this).val()
input_name = $(this).attr('name')
label = $(this).closest('li').find('label')
// Push everything into the questions array
Answer.push({
Answers: answer,
Input_Name: input_name,
Label: label
});
});
$('.submit-holder > input').each(function(){
answer = $(this).val()
input_name = $(this).attr('name')
label = $(this).closest('li').find('label')
Submission.push({
Question: label,
Input_Name: input_name,
Submitted_data: answer
});
});
canvas.push({
Submission: Submission,
Answers: Answer,
Motivation: $('.motivation').val()
});
json = JSON.stringify({json: canvas}, null, "\t");