Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:47:16+00:00 2026-06-13T23:47:16+00:00

i used library datatable and codeigniter i have a variable in view $afd =

  • 0

i used library datatable and codeigniter

i have a variable in view

$afd = "1"

and in this view i have a javascript

<script type="text/javascript" charset="utf-8">

$(document).ready(function() {
$('#datatables').dataTable( {
"bJQueryUI":true,

"bProcessing": true,

"bServerSide": true,

"sPaginationType":"full_numbers",

"sAjaxSource": "<?=base_url()?>index.php/report/report/ajax_view_panen/",

"aaSorting": [[ 0, "asc" ]]

});

});  </script>

to call datatables in controller codeigniter . the function controller is “ajax_view_panen”

this is my controller

function ajax_view_panen()
{
$this->load->library('Datatables');
$this->datatables->from('panen');
$this->datatables->select('id,jml_panen,hariff_blok_id,hariff_afdeling_id,tgl_panen,bulan');
$this->datatables->where('id', $afd);
echo $this->datatables->generate();
}

the question is how to send variable $afd to my controller. so the variable is inside query $this->datatables->where('id', $afd); so the datatables show id = 1

sory for my bad english.

BR

Alex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:47:17+00:00Added an answer on June 13, 2026 at 11:47 pm

    the simpliest way is to send over CI function parameter

    function ajax_view_panen($afd)
    {
      ...
      $this->datatables->where('id', $afd);
      echo $this->datatables->generate();
    }
    

    so you need to pass this variable into your view and call correct url:

    <script type="text/javascript" charset="utf-8">
    ...
    "sAjaxSource": "<?=base_url()?>index.php/report/report/ajax_view_panen/<?=$afd?>",
    ...
    </script>
    

    Note you might need to sanitize your input to be secured.

    Something like $afd = intval($afd) if thats a numeric parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
We are developing web based java application. Richfaces used as library.And we have datatable
I don't know how many people have used this library, but I am using
I have used this library . I have to perform bit operations on BigUnsigned
I need to have library that can be used as memcache with my codeigniter.
I have built a an app in PhoneGap/Cordova and used the JQuery library for
can somebody tell me what is jQuery plugin? I have used the jQuery library
I have a library which has a basic class which is used extensively by
I have a class library used in windows (WPF) and web (ASP.NET) context. The
can anyone help identify the Javascript library used for interactive maps on http://www.africatravelresource.com/ Or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.