开发者

jquery problem in IE with dynamic dropdown selection

Hi jquery/javascript gurus,

I am trying to use jquery ajax function to populate the dropdown, it works fine with FF, but IE give the javascript error snow below in the scrnshot. howver IE does get the data and selects it.

Am i doing something wrong?

开发者_运维问答function getAjaxFunction(thisval, curval) {
    $.ajax({
        type: "POST",
        url: "lookup.do?param="+thisval,
        cache: false,
        success: function(data) {
        var values = data;
        var vals   = values.split(";");
            $("#dropdown").find("option").remove().end();
            for (var i = 0; i < vals.length; i++) {
                var parts = vals[i].split(":");
                $("#dropdown").append($('<option />').val(parts[0]).text(parts[1]));
            }
            $("#dropdown").val(curval);
        }
    });
}

jquery problem in IE with dynamic dropdown selection


You say val(curval) at the end of your function, but your function parameter is named currval with two Rs.


This worked!

function getAjaxFunction(thisval, curval) { 
    $.ajax({ 
        type: "POST", 
        url: "lookup.do?param="+thisval, 
        cache: false, 
        success: function(data) { 
        var values = data; 
        var vals   = values.split(";"); 
            $("#dropdown").find("option").remove().end(); 
            for (var i = 0; i < vals.length; i++) { 
                var parts = vals[i].split(":"); 
                $("#dropdown").append($('<option />').val(parts[0]).text(parts[1])); 
            } 
            try {
                  $("#dropdown").val(curval);
            } catch(ex) {
                  setTimeout("$('#dropdown').val('"+curval+"')",1);
            }
        } 
    }); 
} 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜