开发者

JQuery code not working in IE 8

This code is working in firefox but on IE 8 it returns nothing

<script type="text/javascript">

$(document).ready(function(){

var pageUrl = '<%=ResolveUrl("~/test/test.aspx")%>';

   // Test
        $('#<%=ddlTest.ClientID%>').change(function(){
            var trgId = $(this+'input:checked').val();

            $.ajax({
                type: "POST",
                url : pageUrl+ '/getRecs',
                data : '{categ: "' +trgId + '"}',
                contentType:"application/json; charset=utf-8",
                dataType:"json",
                success:function(msg)
                    { 
                        bindCategories(msg)
                    }
                });
        });
});

$('#divLoad').aja开发者_JS百科xStart(function() {
    $(this).show();
});

$('#divLoad').ajaxStop(function() {
    $(this).hide();
});

function bindCategories(msg)
        {
             if(msg.hasOwnProperty("d"))
                alert(msg.d);
             else
             {
                 $('select[id$=<%=ddlTrg.ClientID %>] > option').remove();

                 $.each(msg, function() {
                    $('#<%=ddlTrg.ClientID %>').append($('<option></option>').val(this['Id']).html(this['Name']));
                 });
             }
        }

</script>`


This line doesn't look right?

var trgId = $(this+'input:checked').val();

this is an html element so you can't just use it like you are.

Do you mean something like:

var trgId = $('#' + this.id).val();

or

var trgId = $(this).find('input:checked').val();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜