Passing values to the controller in the Codeigniter using jQuery load

Passing values to the controller in the Codeigniter.
It took little time to figure out how I can send values together with URL in Codeigniter. After researching little about load jQuery function and Codeigniter, I came to the following solution.
Need: I needed to pass the value of an attribute when the user clicks a link. It should load the controller method dynamically using jQuery.
Solution:
I used load() method of jQuery in the following manner and pass the id as test_id.
In the Codeigniter controller method test, I grabbed the test_id using Codeigniter’s post method, $this->input->post(‘test_id’), alternative could be $_POST[‘test_id’]
And my problem is solved.
//pseudocode $(document).ready(function() { $('.link').click(function(){//element to be click to load the page in the div $('#content').load(path, {test_id: $(this).attr("id")}); }); function test(){ echo $test_id = $this->input->post('test_id', TRUE); } In the view <div id="content"> </div>
Check This Also
Difference between AngularJS and Angular 2 Make a Mobile app in just 10 minutes With Ionic Framework Angular 9: What to Expect in New Version of Angular Alert (Toaster) Notifications in Angular 8Tags: website development company in delhi|| website designing company in delhi || b2b portal development company || magento development company in delhi || website redesigning company in delhi