I'm Having 2 select in my form which one will have the Main Villages and the second one has to show the small villages in depending on the main village selected.
Here is the AJAX request.
<script>
$('#GN_Number').change(function()
{
alert('changed');
$.get('/GN_Number/' + this.value + '/villages.json', function(villages)
{
var $state = $('#Village_ID');
$state.find('option').remove().end();
$.each(villages, function(index, village)
{
$state.append('<option value="' + village.id + '">'
+village.Tamil + '</option>');
});
});
});
And the HTML Code
<tr>
<td>
@if($gn != null)
<select id="GN_Number" class="selector" name="GN_Number">
<option value=""></option>
@foreach($gn as $n)
<option value="{{ $n->id }}">{{ $n->Tamil }}</option>
@endforeach
</select>
@endif
</td>
<td>
<select id="Village_ID" class="selector" name="Village_ID">
</select>
</td>
And the route I have for the Request is as follows
get('GN_Number/{code}/villages.json', function($code)
{
return village_list::where('GN_ID', $code)->get();
});
While I'm testing the code in Chrome Developer mode I don't find any ajax request being made.
Please Check this code and correct me if I'm wrong
Thanks in advance