siva siva - 7 months ago 30
jQuery Question

JQuery on dropdown list change is not working in codeigniter

I am new to code igniter and I have searched the following question in number of StackOverflow threads but none of them seem to solve my problem.

I have the following view code:

<select name="select1" id="select1">
<option value="0">None</option>
<option value="1">First</option>
<script type="text/javascript">

// Ajax post
$(document).ready(function() {
$("#select1").change(function(event) {
var id = $(this).val();
type: "POST",
url: "<?php echo base_url(); ?>" + "index.php/mycontroller/method",
dataType: 'json',
data: {id: id},
success: function(res) {


Ok when I change the drop down list selection nothing happens, which should actually call my controller method. Can you please help me resolve this problem?



You are using <select> id as category

But In jquery you are calling $("#select1").change(function(event) like this .

You just need to change $("#select1").change(function(event) to