I am getting 404 error when I try to contact the Controller.
Please find the information below,
My addslum.blade.php along with the script
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for=""> District</label>
<select name="district_option" id="district_option" class="form-control">
<option value="0" disabled="true" selected="true">------ Select District --------</option>
@foreach ($districts as $key => $district)
<option value=""></option>
@endforeach
</select>
</div>
<div class="form-group">
<label for=""> Municipality</label>
<select name="municipal_option" id="municipal_option" class="form-control">
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$('#district_option').on('change',function(e){
console.log(e);
var municipal_id = e.target.value;
var BASEURL = "{!! url('/engineers-association-guntur/public/admin/feature/') !!};";
console.log(municipal_id);
$.get( BASEURL + 'districtview?municipal_id=' + municipal_id, function(data){
console.log(data);
$('#municipal_option').empty();
$('#municipal_option').append('<option value="0" disabled="true" selected="true">------ Select District First--------</option>');
$.each(data,function(index, municipalObj){
$('#municipal_option').append('<option value="'+ municipalObj.id +'"> '+ municipalObj.municipal_name +' </option>');
})
});
});
</script>
web.php -
Route::get('/addslum', 'newSlumController@listSlums');
Route::get('/engineers-association-guntur/public/admin/feature/municipalview', 'newSlumController@municipalView');
Controller Code:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use App\District;
use App\Municipality;
use Illuminate\Support\Facades\DB;
class newSlumController extends Controller
{
public function listSlums()
{
$districts = District::all();
return view('admin.feature.addslum',compact('districts'));
}
public function municipalView()
{
$districts_id = Input::get('municipal_id');
$municipalities = Municipality::where('district_id', '=', $districts_id )->get();
return response()->json($municipalities) ;
}
I have checked the Chrome Network tool but I could see the the request is being generated to the url but I have didn't get any response.
My apologies if the question is repetitive. I am new to Laravel
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BJSi7p
via IFTTT
Aucun commentaire:
Enregistrer un commentaire