i'm tryng to create a sidebar filters for an e-commerce. I have successfully implemented a infinte scroll pagination, but now i have a problem with filters.
<ul class="check-box-list">
<?php $m = 1; ?>
@foreach($marchi as $marchio)
<li>
<input type="checkbox" id="m" class="marchio" name="" data-marchio="" value="" />
<label for="m">
<span class="button"></span>
<span class="count">()</span>
</label>
</li>
<?php $m++; ?>
@endforeach
</ul>
have this above checkboxes that is generated dynamically. If i click on one of this i can trigger the correct value using this js:
<script type="text/javascript">
$('.marchio').on('click', function() {
var marchio = $('.marchio:checked').val();
$.ajax(
{
url: '?marchio=' + marchio,
type: "get",
beforeSend: function()
{
$('.ajax-load').show();
}
})
.done(function(data)
{
if(data.html == " "){
$('.ajax-load').html("No more records found");
return;
}
$('.ajax-load').hide();
$("#post-data").append(data.html);
})
.fail(function(jqXHR, ajaxOptions, thrownError)
{
alert('server not responding...');
});
});
But if i click a 2nd checkbox, the value appended to the ajax url remaining the same, if i uncheck the first remaining the second. I need to pass to the url multiple values of the same checkbox class by appending it to the url. And if some categorie's can have multiple filter's i need the ajax url can accept different ?querystryngs for example by appending ',' separated values once we click on checkboxes. Can someone help me?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire