Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JQuery Autocomplete no result found

 $(document).on('keyup', ".floor_name", function(){
                if(!$("#project_id").val()){
                    alert("Select Project Name First");
                }else{
                    let project_id  = $("#project_id").val();
                    $(this).closest('tr').find('.floor_id').val('');
                    $(this).autocomplete({
                        source: function( request, response ) {
                            $.ajax({
                                url:"{{route('scj.floorAutoSuggest')}}",
                                type: 'post',
                                dataType: "json",
                                data: {
                                    _token: CSRF_TOKEN,
                                    search: request.term,
                                    project_id: project_id
                                },
                                success: function( data ) {
                                   
                                    if (data.length > 0) {
                                        response( data );
                                } else {
                                    //If no records found, set the default "No match found" item with value -1.
                                    
                                    response([{ 
                                        label: 'No results found.',
                                        val: -1,
                                        floor_id: null
                                    }]);
                                }
                                },
                                error: function(xhr, status, error) {
                                }
                            });
                        },
                        select: function (event, ui) {
                            if (ui.item.val == -1) {
                                $(this).val("");
                                $(this).closest('tr').find('.floor_id').val(ui.item.floor_id);
                                return false;
                            }
                            $(this).val(ui.item.label);
                                $(this).closest('tr').find('.floor_name').val(ui.item.label);
                                $(this).closest('tr').find('.floor_id').val(ui.item.floor_id);
                        }
                    });
                }
            });
Comment

PREVIOUS NEXT
Code Example
Javascript :: js check if string contains character 
Javascript :: querySelectorAll multiple lists 
Javascript :: interpolation in js 
Javascript :: best react native ui library 
Javascript :: table to pdf javascript 
Javascript :: change cover photo with javascript 
Javascript :: jquery parsexml get attribute 
Javascript :: reactjs .net pass value to react 
Javascript :: what is symbol in javascript 
Javascript :: javascript js ternary operater 
Javascript :: js intellisence not working 
Javascript :: while loop vs for loop javascript 
Javascript :: attr jquery 
Javascript :: convert svg to react component 
Javascript :: LocomotiveScroll npm 
Javascript :: hash_hmac javascript 
Javascript :: e editable select no button 
Javascript :: javascript round down to 2 decimal places 
Javascript :: json with postgresql 
Javascript :: canvas draw rect dashed 
Javascript :: inject html via template tags js 
Javascript :: javascript div hover alert 
Javascript :: usestate with object 
Javascript :: Yan Nesting For Loops 
Javascript :: inline if statement javascript 
Javascript :: override backswipe behaviour in ios and android react native 
Javascript :: how to call javascript function with parameter in c# 
Javascript :: testing jest 
Javascript :: javascript null Conversion to Number 
Javascript :: json schema beispiel 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =