I am performing a jQuery .ajax()
call that returns a List<string>
of IP addresses on a specified subnet. I use a [WebMethod]
on an .aspx page to return the values. ASP.NET's built-in JSON serializer does the magic to return the actual JSON used in my Javascript.
I have profiled the the server-side time, and it takes about 8 msec to populate and return the list, so the server-side code is not the issue.
However, when the Ajax call is initiated, in Internet Explorer it can take upwards of 3 seconds to populate a listbox with a small list of IP addresses returned. In Firefox, the listbox is essentially populated instantly.
I'm not entirely certain where the bottleneck could be. My best guess is that the fault lies with IE6's javascript engine, but even so, adding only 255 list items should not take this much time.
Can anyone point me in the right direction as to why this is happening?
Example Code
$.ajax({
type: "POST",
url: $("Example.aspx/GetIPsOnNetwork",
data: "{NetworkID: " + networkID + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
$('#ipAddresses').empty();
// Loop through each IP address and add it to the listbox
$.each(data.d, function(){
var ip = this.toString();
$(document.createElement('option')).attr('value', ip).text(ip).appendTo('#ipAddresses');
});
},
error: function(msg) {
alert('Error: ' + msg);
}
});