[eluser]nuwanda[/eluser]
I'll try to make this clearer for you:
Create a controller method that does something like this to check if the account name is taken:
Code:
function exists(){
$account_name = $this->input->post('account_name');
$table = your_table;
$column = your_column;
$query = $this->db->query("SELECT COUNT(*) AS count FROM $table WHERE $column = '$account_name'");
$row = $query->row();
if($row->count > 0){
echo "Account name already exists";
}else{
echo "Account name is available";
}
}
Note the use of echo to return output to the ajax call.
Then your ajax:
Code:
var account_name_value = $('#account_name_input').val();
$.ajax({
type: "POST",
url: "/controller/exists",
data: ({account_name: account_name_value}),
dataType: "html",
success: function (result) {
//update page with result from exists function
}
});