0

I need to call a php function with parameter from jQuery (DataTable), like above:

table = $('#tbl').DataTable({
        "oLanguage": {
            [...]               
        //"ajax" : "users/list",
        //"data": {"id", "1"},
        "ajax": {
            "url": "users/list",
            "data": {
                "id": 1
            }
          },
            [...]
    });

php function (users.php):

    function list($id){
         [...]
    }

Error message: Missing argument 1 for users::list()

2
  • 1
    follow codeigniter's way of handling URI segments, its supposed to be users/list/1 to actually feed the argument in your method thru URL Commented Apr 12, 2015 at 5:07
  • yes thats about it, you just concatenate it Commented Apr 12, 2015 at 5:23

1 Answer 1

2
var id = $('$control').val;
table = $('#tbl').DataTable({
    "oLanguage": {
        [...]               
    "ajax" : "users/list/" + id,
        [...]
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.