php - how to call a codeigniter function from jquery ajax -


i'm using jquery-datatables-editable plugin @ https://code.google.com/p/jquery-datatables-editable/wiki/editcell#client-side_configuration ci.i have:

<script language="javascript" type="text/javascript">     $(document).ready(function () {        $('#mydatatable').datatable().makeeditable({            supdateurl: "/js/jquery-databatables-editable/ajaxupdate_1.php/index"        });     });  </script> 

on client side page. want able post class ci library class/function on server side, above not seem work. there way this?

that's depends on configuration have.

mostly common, if using default setup:

in javascript file or view (if inline)

<script language="javascript" type="text/javascript">     $(document).ready(function () {        $('#mydatatable').datatable().makeeditable({            supdateurl: "/index.php/your_controller/function_name"        });     });  </script> 

in routes.php

$route["function_name"] = "your_controller/function_name/"; 

lastly, need create function in controller , output expected format:

function function_name(){     echo json_encode('whatever need return'); } 

hope helps!


Comments