0

这是我的 ajax 脚本,这是错误 Uncaught Error: Syntax error, unrecognized expression the code works and removes the second drop down menu but does not append the updated 1

$(document).ready(function(){
    $('#Channel_dropdown').change(function(){
        var channel = $('#Channel_dropdown').val()
        alert(channel);
        $.ajax({
            url: "/advanced_subchannel/",
            type: "GET",
            data: {
                'ch_id' : channel,
            },
            success:function(req){
                $('#subChannel_dropdown').remove();
                $(req).find('#advancedsearch_subchannels').each(function(i){
                    $('#advancedsearch_subchannels').append($(req).find('#subChannel_dropdown'));
                });
            }   
        });
    });
});
4

1 回答 1

0

语法有一些“错误”的小事情

$(document).ready(function () {
    $('#Channel_dropdown').change(function () {
        var channel = $('#Channel_dropdown').val(); //Forgot semicolon
        alert(channel);
        $.ajax({
            url: "/advanced_subchannel/",
            type: "GET",
            data: {
                'ch_id': channel //Extra unneeded comma
            },
            success: function (req) {
                $('#subChannel_dropdown').remove();
                $(req).find('#advancedsearch_subchannels').each(function (i) {
                    $('#advancedsearch_subchannels').append($(req).find('#subChannel_dropdown'));
                });
            }
        });
    });
});

有些网站可以为您验证 javascript,请查看http://jsfiddle.net/他们有一个使用http://www.jslint.com/的内置验证器

于 2013-04-16T23:42:23.250 回答