A Web service returns a list of system users in the following format. You need to populate a drop-down menu with the IDs and names of the users from the Web service, in the order provided by the service. Which code segment should you use?()
- A、$.ajax({type: "GET", url: serviceURL, success: function(xml) { $.each($(xml), function(i, item) { $("").attr("value", id).text(tx).appendTo("#dropdown"); }); } });
- B、$.ajax({ type: "GET", url: serviceURL, success: function(xml) { $(xml).find("user").each(function() { var id = $(this).id; var tx = $(this).name.text $("").attr("value", id).text(tx).appendTo("#dropdown"); }); } });
- C、$.ajax({ type: "GET", url: serviceURL, success: function(xml) { $(xml).find("user").each(function() { var id = $(this).attr("id"); var tx = $(this).find("name").text();$("").attr("value", id).text(tx).appendTo("#dropdown"); }); } });
- D、 $.ajax({ type: "GET", url: serviceURL, success: function(xml) { xml.find("user").each(function(node) { var id = $(node).attr("id"); var tx = $(node).find("name").text(); $("").attr("value", id).text(tx).appendTo("#dropdown"); }); } });
正确答案:C
答案解析:有
微信扫一扫手机做题