I'm building a JSON array out of submitted data in a form, but this script is breaking and can't figure out what is causing it!
Any ideas?
Jquery:
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");