Question : check if the request is ajax request in laravel
Answered by : muhammad-ishaq
if($request->ajax()){ return "ajax request";
}
Source : | Last Update : Mon, 21 Mar 22
Question : ajax get request in laravel
Answered by : abhijith
$(document).ready(function() { $('#country').change(function () { var country_id = this.value; $.ajax({ url: '{{url('/')}}/admin/lottery_master/getstatesbycountry/'+country_id, dataType: 'json', type: 'GET', error: function() { toastr.error('Server error occured', Error, { CloseButton: true, ProgressBar: true }); }, success: function(data) { var sel = $("#state"); var stateList = data.state; sel.empty(); sel.append('<option value="">-- Select State --</option>'); for (var i=0; i<stateList.length; i++) { sel.append('<option value="' + stateList[i].id + '">' + stateList[i].state_name + '</option>'); } }, }); });
});
Source : | Last Update : Fri, 12 Aug 22