DKR DKR -4 years ago 133
Ajax Question

Cannot send session cache limiter - headers already sent - CodeIgniter(Session.php)

Please don't mark it as duplicate without reading complete question.

I know this is discussed already many times.

But this is different case.

I am making a simple ajax call to a php method which is as below:

public function updateAbout()
{
log_message('debug', "updateAbout is called", false);

log_message('debug',$this->input->post('fname'), false);

log_message('debug', "updateAbout success", false);

}


In this method I am simply trying to get data which is passed by ajax call.

But I don't get data posted by ajax call instead get 2 errors:

Severity: Warning --> session_start(): Cannot send session cache limiter - headers already sent ...\..\\libraries\Session\Session.php 143
Severity: Warning --> Cannot modify header information - headers already sent ..\..\libraries\Session\Session.php 171


Note:

I am not using session_start(); anywhere in my project.

This error is pointing to session_start() method which is in Session.php file of Codeigniter libraries. It is not pointing to anywhere in my code so I am not sure where do I look for issues.

I have already checked answers all over internet and none of them seem to solve this issue.

Can someone explain me why I am getting this error and how can I prevent this?

Thank you.

Edit:
As per suggestions in other answers, I have checked and removed spaces in in all my codes.

Here is my javascript code where ajx call is made.

$("#btnupdateAbout").click(function(){

$fname=$("#updatefname").val();
$lname=$("#updatelname").val();
$country=$("#updatecountry").val();
$locality=$("#updatelocality").val();

if($('#optradioMale').is(':checked')) { $gender="Male"; }
else{$gender="Female";}

$.ajax({

url:"http://localhost/Voyager/ProfileControls/updateAbout",
data:{'fname':$fname,'lname':$lname,'country':$country,'locality':$locality,'gender':$gender},
method:"POST",
contentType:false,
cache:false,
processData:false,

success:function(){

}

});
});

Answer Source

Make use of F12 in your browser during the ajax call and and click on console and network to see your ajax call details, sometimes an error occur due to deprecated methods and you need to change some php settings in php.ini like

always_populate_raw_post_data = -1

also if you are using routes.php make sure you are using the correct path

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download