I receive data from a table. And save them in array.
I am wondering how to convert array into string with the following format.
In my request,users can add new rows and type in questions and answers.
That's why I think I can put all data in the "form:input"
My code:
var param = [];
$("#tblPets tbody tr").each(function(index){
param.push({
question: $("textarea.question", this).val(),
answer: $("textarea.answer", this).val(),
});
});
var json = JSON.stringify(param);
$("form #queAns").val(json);
I can convert this array into JSON string.but the format is not what im looking for.
For example:
I hope my string can look like:
Question,Answer|Question,Answer|Question,Answer|
How to do this??