JQuery datepicker not working after ajax call

后端 未结 5 1610
一向
一向 2021-01-18 09:57

I have the following code


    
       //included all jquery related stuff ..not shown here
    
    
               


        
5条回答
  •  臣服心动
    2021-01-18 10:28

    You need to reinitialize the date picker in Ajax success

    $('.datepicker').datepicker({dateFormat: "dd-mm-yy"});
    
    $('#btn').click(function() {
        $.ajax({
            type: "GET",
            url: "my_ajax_stuff.php" ,
            success: function(response) {
    
                $('#ct').html(response);
                $( "#datepicker" ).datepicker();
                /*added following line to solve this issue ..but not worked*/
                //$( ".datepicker" ).datepicker({dateFormat: "dd-mm-yy"});
    
            } ,
            error: function () {
                $('#ct').html("Some problem fetching data.Please try again");
            }
        });
    });
    

提交回复
热议问题