I'm creating an app for a project and I'm stuck with this feature. I've already created a POST method for the checked checkboxes but I don't know how to get that information and then display it on my HTML page. I'm not sure with my GET method. It's basically an edit page feature. And we're only supposed to use AJAX and flask. Please help.
function edit_food() {
console.log($('input[name="food"]:checked').serialize());
$.ajax({
url: 'http://ift.tt/2rxDCl8',
data: JSON.stringify({}),
type: "POST",
dataType: "json",
success: function (newSet) {
$('input[name="food"]:checked');
if (newSet.status == 'ok') {
alert("SAVED!")
}
},
error: function (e) {
alert("Something went wrong!");
}
});
var $set = $('#set');
$.ajax({
url: 'http://ift.tt/2qOoN0g',
data: JSON.stringify({}),
type: "GET",
dataType: "json",
success: function (set) {
$('input[name="food"]:checked');
if (set.status == 'ok') {
alert("SAVED!")
}
},
error: function(e) {
alert("Something went wrong!");
}
});
}
Aucun commentaire:
Enregistrer un commentaire