According to my scenario when I select a doctor whose id is #slmc, I want to retrieve data relevant to the doctor I have chosen..
This is my blade File -> Admin/channel.blade
<label id="lslmc" for="slmc" class="control-label">Choose a Doctor </label><br />
<select class="form-control" id="slmc" name="slmc" onchange=" getPatient()" >
<option value="">----Select the Doctor----</option>
@foreach($Doctors as $Doctor)
<option value ="{{$Doctor-> slmc}}">{{$Doctor->fname}} {{$Doctor->sname}} </option>
@endforeach
</select>
</div>
<div id ="dd"></div>
Then this is my getPatient() function in the controller
public function getPatient($slmc){
$patients = DB::table('channel')->where('slmc', $slmc)->get();
return $patients;
}
This is the Ajax call in the script function.
function getPatient() {
var patient = $("#slmc").val();
$.ajax(
{
type: 'get',
url: ('/Admin/channel/getPatient'),
data: {'patients': patient},
success: function (data) {
$('#dd').html("");
$('#dd').html(data);
}
}
);
}
This is web.php
Route::get('/Admin/channel/getPatient{slmc}', 'channelController@getPatient' );
Is there something wrong with my Ajax call. I'm new to it.