onclick="cat_ajax_get(...)"
looks for a function in the global Javascript scope. This line:
jQuery(document).ready(function($){
hides everything from the global scope. So, this won’t work.
You will have to use a completely different technique here. Do not set the onclick
attribute. Instead attach the handler from inside your Javascript code:
jQuery(document).ready(function($){
var links = $(".filter a.ajax");
var ajaxurl="<?php echo admin_url( "admin-ajax.php" ); ?>";
function cat_ajax_get (event) {
var catIDText = $(event.target).parent().prop('id');
var catID = catIDText.substring(4);
links.removeClass("selected"); // remove class from all lines
$(event.target).addClass("selected"); // only add it back on the selected
$.ajax({
type: 'POST',
url: ajaxurl,
data: {"action": "load-filter", cat: catID },
success: function(response) {
$("#category-post-content").html(response);
return false;
}
});
}
links.click(cat_ajax_get);
});