Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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 Read File modes 
Php :: Laravel retrieving single record 
Php :: The `url` supplied for the path (./nova) repository does not exist 
Php :: laravel run schedule locally 
Php :: php array remove key value pair 
Php :: delete directory from laravel storage 
Php :: mysql secure 
Php :: laravel multiple orderby 
Php :: pluck array in laravel 
Php :: angular post phph 
Php :: php auto redirect 
Php :: how to install php dependencies 
Php :: send html email laravel 
Php :: get data based on date in laravel 
Php :: laravel-medialibrary packagist 
Php :: php keys of array 
Php :: laravel make auth 
Php :: how get query logs in laravel 
Php :: remove item in an array php 
Php :: symfony see all make command 
Php :: check if elquent retrun empty array laravel 
Php :: php session name 
Php :: php if else 
Php :: web scraping in php 
Php :: textarea laravel migration 
Php :: foreach skip current iteration 
Php :: insertgetid laravel 8 
Php :: laravel db insert get last id 
Php :: convert time to 24 hour format laravel 
Php :: add text to image and save php 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =