我需要做一个以下清单的帖子,这是一个数组列表 “清单”:[ “卢格”, “Presupuesto”, “直径”]
我的问题是我不知道我该怎么办。这是我的js
function crearTodo(nuevoTodo){
var url = API_URL;
var todo = JSON.stringify(nuevoTodo);
$("#button_to_create").click(function(e){
$("#create_result").text('');
e.preventDefault();
var nuevoTodo ;
if($('#id_to_create').val() == "" || $('#summary_to_create').val()==""){
$('<div class="alert alert-info">Debes rellenar los campos ID y summary</div>').appendTo($("#create_result"));
}else if (isNaN($('#id_to_create').val())){
$('<div class="alert alert-info">La ID del nuevo TODO debe ser numerica </div>').appendTo($("#create_result"));
}else{
nuevoTodo = {
"id" : $("#id_to_create").val(),
"description" : $("#description_to_create").val(),
"summary" : $("#summary_to_create").val(),
"checklist" : $("#checklist_to_create").val(),
"date" : $("#date_to_create").val()
}
crearTodo(nuevoTodo);
}
});
$("#create_result").text('');
$.ajax({
url: url,
type : 'POST',
crossDomain :true,
dataType : 'json',
data : todo,
statusCode: {
404: function() {$('<div class="alert alert-danger"> <strong>Oh!</strong> Page not found </div>').appendTo($("#create_result"));}
}
}).done(function(data, status, jqxhr) {
$("#summary_to_create").val();
$("#id_to_create").val();
$("#description_to_create").val();
$("#checklist_to_create").val();
$("#date_to_create").val();
$('<div class="alert alert-success"> <strong>Ok!</strong> Todo creado</div>').appendTo($("#create_result"));
console.log(data);
}).fail(function() {
$('<div class="alert alert-danger"> <strong>Oh!</strong> Error </div>').appendTo($("#create_result"));
});}
和我的html,我不知道如何介绍这个数组
<div class="row">
<div class="col-sm-8">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Crear un nuevo TODO</h3>
</div>
<div class="panel-body">
<div class="input-group input-group-sm">
<span class="input-group-addon">ID</span> <input
type="text" class="form-control" id="id_to_create">
</div>
<div class="input-group input-group-sm">
<span class="input-group-addon">Descripcion</span> <input
type="text" class="form-control" id="description_to_create">
</div>
<div class="input-group input-group-sm">
<span class="input-group-addon">summary</span> <textarea
type="text" class="form-control" id="summary_to_create"></textarea>
</div>
<div class="input-group input-group-sm">
<span class="input-group-addon">checklist</span> <textarea
type="text" class="form-control" id="checklist_to_create"></textarea>
</div>
<div class="input-group input-group-sm">
<span class="input-group-addon">date</span> <textarea
type="text" class="form-control" id="date_to_create"></textarea>
</div>
<span id="create_result"></span>
</div>
</div>
</div><!-- /.col-sm-8 -->
<div class="col-sm-4">
<button type="button" class="btn btn-info" id="button_to_create">Create TODO</button>
</div>
</div>
感谢