Here is the checkbox that I target:
$query = " SELECT DISTINCT(collection) FROM products";
$featured = mysqli_query($conn,$query);
while ($row = mysqli_fetch_assoc($featured)){?>
<div class="list-group-item checkbox" style="background-
color: #f4f4f4;">
<label><input type="checkbox" class="common_selector
collection" style="" value="<?php echo
$row['collection']; ?>" id='<?=$row["collection"];?
>'><?php echo $row['collection'];?></label>
</div>
<?php } ?>
Here is the AJAX:
$("input:checkbox").change(function(){
var product_collection = $(this).attr('id');
var action = "coll";
console.log(product_id);
$.ajax({
url:"../PHP_Scripts/fetch_data.php",
method: "POST",
dataType: "json",
data:{
product_collection:product_collection, action:action
},
success:function(){
alert("hello");
}
});
});
And here is fetch_data.php
header("Location: page_2.php");
As you can see, I just want it to redirect to a different page. The success
does not send and I can't find what is wrong with the code.
The network tab shows that the data does get sent with a code of: 200 and it does contain the data that needs to be sent. Any ideas?
Aucun commentaire:
Enregistrer un commentaire