AJAX Request Erroring
Posted
by
30secondstosam
on Stack Overflow
See other posts from Stack Overflow
or by 30secondstosam
Published on 2012-12-10T10:54:59Z
Indexed on
2012/12/10
11:04 UTC
Read the original article
Hit count: 194
I can not figure out for the life of me why this is erroring - can someone please cast a second pair of eyes over this - it's probably something really stupid, thanks in advance for the help:
EDIT Stupidly I was putting the wrong URL in - HOWEVER... Now I have put the correct URL in, the site just hangs and crashes. Any ideas please?
HTML:
<input id="pc" class="sfc" name="ProdCat[]" type="checkbox" value="">
<input id="psc" class="sfc" name="ProdSubCat[]" type="checkbox" value="">
<input id="bf" class="sfc" name="BrandFil[]" type="checkbox" value="">
JQuery:
$('input[type="checkbox"]').change(function(){
var name = $(this).attr("name");
var ProdCatFil = [];
var ProdSubCatFil = [];
var BrandFil = [];
// Loop through the checked checkboxes in the same group
// and add their values to an array
$('input[type="checkbox"]:checked').each(function(){
switch(name) {
case 'ProdCatFil[]':
ProdCatFil.push($(this).val());
break;
case 'ProdSubCatFil[]':
ProdSubCatFil.push($(this).val());
break;
case 'BrandFil[]':
BrandFil.push($(this).val());
break;
}
});
$("#loading").ajaxStart(function(){
$(this).show();
$('.content_area').hide();
});
$("#loading").ajaxStop(function(){
$(this).hide();
$('.content_area').show();
});
$.ajax({
type: "GET",
url: '../ajax/ajax.php',
data: 'ProdCatFil='+ProdCatFil+'&ProdSubCatFil='+ProdSubCatFil+'&BrandFil='+BrandFil,
success: function(data) {
$('.content_area').html(data);
}
}).error(function (event, jqXHR, ajaxSettings, thrownError) {
$('.content_area').html("<h2>Could not retrieve data</h2>");
//alert('[event:' + event + '], [jqXHR:' + jqXHR + '], [ajaxSettings:' + ajaxSettings + '], [thrownError:' + thrownError + '])');
});
PHP (just to prove it's working):
echo '<h1>TEST TEST TEST </h1>';
The errors from JQuery alert box:
[event:[object Object]], [jqXHR:error], [ajaxSettings:Not Found], [thrownError:undefined])
© Stack Overflow or respective owner