javascript - JQUERY 自动完成功能在 chrome 和 firefox 中工作,但在 IE 中不起作用

标签 javascript jquery ajax internet-explorer autocomplete

我使用函数中的变量来创建自动完成功能,代码如下:

 function autocomplete(mp_info){
        var request_data = {
                '_action': 'GET'
            };
        $(mp_info).find("#id_mp_element").autocomplete({
            source: function( request, response, elems ) {
                    alert("working");
                    $.ajax({
                        url: "/api/slots/"+request.term+"/12/",
                        dataType: "json",
                        type: 'POST',
                        data: request_data,
                        success: function( data ) {
                            response($.map(data, function(item) {
                                return {
                                    label: item.name,
                                    id: item.id,
                                    pos: item.position
                                }
                            }));
                        }
                    });
                },
                minLength: 2,
                select: function( event, ui ) {
                    var info_row = $(".info_row").has(this);
                    $($('td',info_row.parent().prev())[2]).text($(".info_row     #id_mp_element").val()+" / "+ui.item.pos);
                    $("#id_mp_s").val(ui.item.id);
                    $("#id_mp_position_metric").val(ui.item.pos);
                },
        });
    }   

当我们在文本输入中写入内容时,IE 中不会显示警报消息

最佳答案

删除末尾的昏迷:

 select: function( event, ui ) {
                var info_row = $(".info_row").has(this);
                $($('td',info_row.parent().prev())[2]).text($(".info_row     #id_mp_element").val()+" / "+ui.item.pos);
                $("#id_mp_s").val(ui.item.id);
                $("#id_mp_position_metric").val(ui.item.pos);
            }            <------- there shouldn't be a come here
    });

关于javascript - JQUERY 自动完成功能在 chrome 和 firefox 中工作,但在 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14732264/

相关文章:

javascript - 将 Javascript 对象的内容附加到 HTML

jquery - css - 在内容上方 float 页眉和页脚,使用 jquery 自动调整背景大小

android - phonegap android 应用程序中的 HTML5 属性类型 "time"挂起该应用程序

JQuery 验证事件设置

javascript - AJAX:表单提交以发表评论

javascript - 传递给 history.pushState 的状态对象是什么,它有什么作用?

javascript - `throw` 和字符串连接的行为不明确

javascript - PHP 中 JS : something. toFixed() 的确切等价物是什么?

javascript - 如何用Ractive响应img加载事件?

javascript - IE 的非冒泡提交事件的解决方法