Welcome Guest, Not a member yet? Register   Sign In
Calling a CI library from a javascipt?
#4

[eluser]jalalski[/eluser]
I have a controller (application/controllers/admin/customers.php) that has a bunch of methods for working with customers. One of the methods is 'find_like' which then calls a search on the Customers model and returns json_encoded string to the caller:
Code:
class Customers extends Controller {
  ....
  ....
  function find_like($param='') {
    $param = $this->input->post('term');
    log_message('message', 'ADMIN: customers::find: ' . $param);
    $this->load->model('Customers_model', 'Customers');
    $matches = $this->Customers->find_like($param);
    print json_encode($matches);
    return true;
  }
}

This function is then available to the caller as:
index.php/app/admin/customers/find_like/

Remember to tell ajax to use POST, not GET for the autocomplete.


Messages In This Thread
Calling a CI library from a javascipt? - by El Forum - 11-10-2010, 09:25 PM
Calling a CI library from a javascipt? - by El Forum - 11-11-2010, 01:44 AM
Calling a CI library from a javascipt? - by El Forum - 11-11-2010, 03:32 AM
Calling a CI library from a javascipt? - by El Forum - 11-11-2010, 04:27 AM
Calling a CI library from a javascipt? - by El Forum - 11-11-2010, 09:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB