Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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>');
                }
            },
		});
    });

}); 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ajax #request #laravel
ADD COMMENT
Topic
Name
4+8 =