autocomplete showing self.element.propAttr error

2020-08-14 07:54发布

I am using Jquery ui Autocomplete.But it show error autocomplete showing self.element.propAttr error. this is my ajax code

$.ajax({
        url: "persons.xml",
        dataType: "xml",
        success: function( xmlResponse ) {
            var data = $( "person", xmlResponse ).map(function() {
                return {
                    value: $( "name", this ).text()

                };
            }).get();
            $( "#birds" ).autocomplete({
                source: data,
                minLength: 0

            });


        }

    });

I am using xml for response but that doesnot seem to be the problem it seems some function in javascript is deprecated. Can anyone give me any solutions for this?

2条回答
戒情不戒烟
2楼-- · 2020-08-14 08:12

Add this lines in front of your statement:

jQuery.fn.extend({
 propAttr: $.fn.prop || $.fn.attr
});
查看更多
我想做一个坏孩纸
3楼-- · 2020-08-14 08:26

I was facing this problem when refactoring my javascript and found that the problem was I removed jquery.ui.core.js, and instead was using only jquery-ui-1.9.1.custom.min.js.

I created this file using the Download Builder at the Jquery UI website with everything checked. Correct me If I am wrong but jquery-ui-1.9.1.custom.min.js should have contained all the javascript necessary to run all the jquery ui addins (in this case autocomplete was failing).

Adding the reference back to jquery.ui.core.js fixed the bug.

查看更多
登录 后发表回答