I have a list of different types of articles I display on my page. You can check or uncheck the types to make them display/hide from the article spawner. With my current array builder in jquery it cant be passed properly through ajax to the $_POST in php.
My function that is triggered everytime a checkbox is unchecked/checked
$(".jquery-checkbox").change(function(){
var data = new Array();
//check all the different types and see if they are checked or not
$(".jquery-checkbox").each(function() {
//if the type is not checked, put it into the data array to filter from results
if(!$(this).is(':checked')){
data[$(this).attr("name")] = $(this).attr("name");
}
});
$.ajax({
type: "POST",
url: "/Ajax/article/articleList.php",
dataType: "html",
data: data,
success: function(data) {$("#article-spawner").html(data);},
error: function(){return false;}
});
});
Is there a I can find each type that isn't checked and put them in an array in this form:
var data = {
"8":"not-checked",
"10":"not-checked"
};
It works with the above method but I'm not sure how to reach this method using .each