CodeIgniter Forums
Unable to get Response from ajax - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Unable to get Response from ajax (/showthread.php?tid=46807)



Unable to get Response from ajax - El Forum - 11-16-2011

[eluser]Gukkie[/eluser]
Hi, i have a small problem here which i cannot fix, i am trying to get a rsponse from an ajax call to the controller function. The post goes through but the response returns a "500 internal server error"

Why is this so? What am i doing wrong?

JS:
Code:
function getState(countryId)
{
var dataString = "countryId="+countryId;

$.ajax({
  type: "POST",
  url : baseUrl + 'user/getState',
  data: dataString,
  cache : false,
  success : function(response){
   alert(response);
   }
});
}

Controller:
Code:
function getState()
{
  if($this->input->is_ajax_request())
  {
   $countryID = $this->input->post('countryId');
  
   echo $countryID;
  }
}