Monday, November 28, 2022
LaravelLaravel 5.8Uncategorized

Laravel select2 with json data working example


Hello to all, welcome to In this post, I will tell you, Laravel select2 with json data working example.


Here is the complete working code and you can add this any of your’s laravel blade template file:
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">


        <!-- Fonts -->
        <link href=",600" rel="stylesheet">
        <link rel="stylesheet" href="">
        <link href="" rel="stylesheet" />
        <script src=""></script>
        <script src=""></script>

        <!-- Custom Script -->
        $(document).ready(function() {
            var sampleArray = [{id:'AL',text:'Alabama'}, {id:'WY',text:'Wyoming'}];
            $('.js-example-basic-single').select2({data: sampleArray});
    <div class="jumbotron text-center">
    <div class="container">
        <div class="row">
            <div class="col-sm-8">
            <select class="js-example-basic-single form-control" name="state">
                <option value="AL">Alabama</option>
                <option value="WY">Wyoming</option>

If you have any query related to this post, then please let me know.


Thank you

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 8, Angular 9, Angular 10, Angular 11, Angular12, Angular 13, Angular 14, Angular 15, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.