Skip to content
Advertisement

Calling Controller method from javascript using CodeIgniter

I am using CodeIgniter ..I can’t access the method from the controller

I have this script in my view

JavaScript

and i have a controller named ajax with a method ajaxSearch()

JavaScript

Folder Structure

JavaScript

What could be the possible problem here?

Advertisement

Answer

Do the following…

In controller create example.php and leave ajax.php like it is. And in views leave like you have already view_ajax.php

We are going to load data from example.php with Ajax

Your ajax.php should look like this

JavaScript

JavaScript code for testing purpose write like

JavaScript

Nest Step

example.php should look like this

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement