echo json_encode($data,TRUE) is not going back to the ajax function in codeigniter -


my code is

<script>  $("#saveexpense").click(function(){      alert('i in jquery function');     $.ajax({         type:'get',          url: "<?php echo site_url('expenses/addexpense');?>",         datatype: 'json',         data:$('#addexpenseform').serialize(),          success: function(response) {             comsole.log(response);             var curlen = response.length;              var htm = curlen+"| &nbsp;"+response[curlen-1].category+"| &nbsp;"+response[curlen-1].amount+"| &nbsp;"+response[curlen-1].comments+"| &nbsp;edit/delete<br />";               $("#showexpenses").append(htm);          }     });  }); 

my controller

function addexpense(){     if(!$this->session->userdata('logged_in'))         redirect('expenses','refresh');     $this->expenses_model->addexpense();     $data=$this->expenses_model->viewexpenses();     echo json_encode($data,true); } 


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -