Hi,
I'm using the big cartel framework to build a site, and am trying to make an AJAX call - currently without success. My code is as follows:
jQ('body').on('click','#closeDetails',function(){
// If necessary condition met
if (jQ('#productDetails').attr('class') != undefined){
// Store appropriate category
var destCategory = jQ('#productDetails').attr('class').toLowerCase();
// Attempt to alert products from category
// Taken from http://help.bigcartel.com/customer/portal/articles/772751-javascript-ajax
jQ(function() {
Product.findAll({ category: destCategory }, function(products) {
alert("I found " + products.length + " products!");
});
});
} else {
// Code that works goes here
}
});
So, when the user clicks on #closeDetails
- if the condition returns true - find the correct category value (works fine), then use this value to try and retrieve all products from the category, and (for now) simply alert the number found.
Currently the alert simply says "Error:" and Chrome's console says "Failed to load resource: the server responded with a status of 404 (Not Found) - http://www.webaddress.co.uk/products.js?category=category1".
I've only been working with javascript for a few weeks, so am guessing I've made a syntax error. What am I doing wrong?
Thanks.