Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel check request is ajax

         /**       
         * Display a listing of the resource.
         *
         * @param  IlluminateHttpRequest $request
         * @return Response
         */
        public function index(Request $request)
        {
            if($request->ajax()){
                return "AJAX";
            }
            return "HTTP";
        }
Comment

ajax get request in laravel

$(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>');
                }
            },
		});
    });

}); 
Comment

check the ajax request in laravel

if($request->ajax()){
  return "ajax request";
}
Comment

PREVIOUS NEXT
Code Example
Php :: php header redirect with parameters 
Php :: laravel assets path 
Php :: laravel validation unique email except self 
Php :: carbon previous day 
Php :: AUTO_INCREMENT in laravel 
Php :: with message in laravel 
Php :: larave Soft Deletes 
Php :: laravel route only and except 
Php :: php round up 
Php :: laravel tree 
Php :: find substring in string php 
Php :: Merge Two Collection or Array 
Php :: filename php 
Php :: laravel eloquent without relation 
Php :: mcrypt php extension required 
Php :: remove certain haracters from a string php 
Php :: how increase php upload size in wordpress 
Php :: redirect in php 
Php :: laravel factory get foreign key 
Php :: php value to javascript variable laravel blade 
Php :: php array sum 
Php :: why storage link do not work in host for laravel 
Php :: symfony get container static 
Php :: laravel cache remember 
Php :: php datetime add 1 weeek 
Php :: string match in php 
Php :: php mail 
Php :: format a number with leading zeros in php 
Php :: Best debugging tools for php 
Php :: Group by not working - Laravel 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =