views:

72

answers:

2

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);
        }
    });
}

alt text

A: 

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

ithcy
sorry that was just a typo. i still have the same problem, and as i mentioned it works fine in FF, not in IE.
Shah
A: 

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);
            }
        } 
    }); 
} 
Shah