Following of my code which is working fine in code ignitor 1.7.1 now not able to invoke controller method user/checkAvailability?requestSource=USER_AVAILABILITY it goves to error block and printing alert as alert('In side Error');
I found that none of Jquery Ajax request not working ..
not able to understand why its not going to call controller method,
Please help
function checkAvailability(){ $.blockUI({message: null});
var newMessage = 'E1';
$('#searchLoading').show(); alert('I am here'); $.ajax({
type: "post",
url: "user/checkAvailability?requestSource=USER_AVAILABILITY",
cache: false,
data: "userName=" + $("#userName").val(),
success: function(json){
alert("Printing Json");
try{
$.unblockUI();
var obj = JSON.parse(json);
if(obj[0].STATUS=='true'){
newMessage = "E15";
$('#checkUser').hide();
}else{
newMessage = "E16";
$("#checkUser").hide();
}
showMessage(newMessage);
$('#searchLoading').hide();
}catch(e) {
alert('In side Exception');
showMessage("E1");
$.unblockUI();
$('#searchLoading').hide();
}
},
error: function(){
alert('In side Error');
$('#searchLoading').hide();
$.unblockUI();
$("#checkUser").hide();
showMessage(newMessage);
$( "form" )[0].reset();
} });
}
CI Method in controller User
/**
This method is used to check User Name availabiliy.
*/
public function checkAvailability(){
$userName = trim($this->input->post('userName'));
$query = $this->UserModel->getUser($userName);
$status =array("STATUS"=>"true");
if($query){
$status = array("STATUS"=>"false");
}
echo json_encode (array($status)) ;
}