[英]Failed to load resource: the server responded with a status of 500 (Internal Server Error) - Angularjs and Codeigniter
[英]Failed to load resource: the server responded with a status of 500, Codeigniter project
我正在嘗試使用ajax發送呼叫,但在Chrome中它出現上升錯誤,但在Firefox中沒有錯誤。 但是仍然不能調用該方法。 這附加顯示7個div,但是一些div被加載但是一些div繼續加載而控制台顯示錯誤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));
}
這是視圖部分
$('#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>');
這是Ajax函數
/* 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");
}
}
});
}
我懷疑這一行
url="<?php echo "/./home-recent-articles-filter-cat/";?>"+category+"/"+limit+"/";
Codeigniter URL看起來不像這樣。 它至少包含3個參數(除非有index
功能)
所以它應該是這樣的
url = <?= base_url(); ?>.'controller_name/get_recent_articles'
確保這些已加載
short_tag=On
檢查這些
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.