I'm trying to send a call using ajax but in Chrome it is rising error but in firefox there is no error. But still it can't calling the method. THis append shows 7 divs, but some div gets loaded but some of div keeps loading and console shows error 500
//get recent posts via ajax controller class
public function get_recent_articles($cr_post_id,$category,$limit,$offset)
{
$recent_post=$this->Post_model->get_recent_articles($cr_post_id,$category,$limit,$offset);
return $this->output
->set_content_type('application/json')
->set_status_header(200)
->set_output(json_encode($recent_post));
}
Here is view part
$('#recent_post_cat_2').show();
$('#recent_post_cat_2').append('<div id="recent_post_cat_2_preloader" class="col-md-12 col-sm-12 text-center" style="vertical-align:middle;padding:15px 0px;"><i class="fa fa-spinner fa-spin" style="font-size:24px"></i></div>');
Here is Ajax function
/* START - get_recent_articles*/
function get_recent_articles(category,div_id,limit)
{
//prepare url
url="<?php echo "/./home-recent-articles-filter-cat/";?>"+category+"/"+limit+"/"; $.ajax({
url: url,
type: 'GET',
dataType: "json",
crossDomain: true,
success: function(data){
// console.log(JSON.stringify(data));
if(data.status=="success")
{
prepared_posts_data=prepare_cards(category,data.data,3);
$(div_id+'_preloader').remove();
$(div_id).append(prepared_posts_data);
$(div_id).show();
var myLazyLoad = new LazyLoad({
threshold: 50,
callback_load: function(e) {
// console.log($(e).attr("data-original") + " loaded" );
}
});
}
else{
console.log("no posts available");
}
}
});
}