[eluser]taewoo[/eluser]
Since CI community is so giving, i shall give back.
Controller/method that gets called
Code:
function search_club_name($city, $state, $name)
{
header('Content-Type: application/json');
$this->load->model('club_model');
$club_names = $this->club_model->getByClubUrl( $city, $state, $name );
echo count($club_names);
}
And the AJAX code
Code:
var url = '/ajax/search_club_name/'+ city_string + "/" + state_string + "/" + name_string;
new Ajax.Request(url, {
method: 'get',
onComplete: function(response) {
//alert('Complete: ' + Object.inspect(response.responseText));
if(response.responseText == 0) {
submitClubForm();
} else {
var msg = 'Club name"' + name_string + '" has been taken for city of '+ city_string +', '+ state_string + '. Please choose a different name/city combination.'
alert(msg);
}
}
});