I have the following script which works fine:
$.ajax({
url: 'serverside_script',
type: 'GET',
dataType: 'json',
error: function(xhr, status, error) {
alert('Error: ' + status + '\nError Text: ' + error + '\nResponse Text: ' + xhr.responseText);
},
success: function(results) {
var len = results.length;
for(i=0; i<len; i++) {
$("#tabs").tabs("add","tabs.aspx?tab=" + results[i].key, results[i].value)
};
}
});
Is it possible to convert the for loop to a more jquery type $.each loop?
Why yes it is. The function provided can take up to two arguments: first the key, and finally the individual object being iterated.
See the reference for more information on the jQuery.each function.