开发者

jQuery Javascript loading continuously in CodeIgniter

I开发者_运维百科 am developing one application using PHP, jQuery, Javascript in CodeIgniter.

I included script.js file in view file. The problem is the view file is continuously loading again and again with in the result div called "new".

Please help me. Below are the files and code.

View file

<?php $this->load->view('header'); ?>
 <script type="text/javascript" src="<?php echo base_url();?>js/script.js"></script>
<div id="content"> 
<div id="news">
</div>
</div>

script.js has the following code:

$.post('news/getnews', function(data) {

  $('#news').append(data);
});

In controller,

function getnews()
{

  echo some data.
}

It only loading the result again and again when I use Post, ajax etc methods. i.e, when I try to get data from controller and append to view using Javascript.

Thanks, Raj


Please try

$('#news').html(data);


Uh... is your view file named getnews? If so then you it will continuously be calling itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜