jonatec
asked on
jQuery how to get returned .ajax() element count ?
My attached code calls a Web Service. I am trying to determine if it returns any elements, if none found I can put out a suitable message.
Please check my code, the .size() keeps returning 0, where am I going wrong with this?
[ thanks ]
Please check my code, the .size() keeps returning 0, where am I going wrong with this?
[ thanks ]
function fnGetDictDefinition() {
$.ajaxSetup({ cache: false });
$.ajax({
type: "GET",
url: "http://services.aonaware.com/DictService/DictService.asmx/Define",
data: "word=" + $("#txtWord").val(),
dataType: "xml",
success: function(xml) {
var name = "";
var word_def = "";
var buf = "";
var found = $("xml").find("Definition");
alert(found.size())
$(xml).find("Definition").each(function() {
name = $("Name", this).text();
buf += "<b>Dictionary:</b> " + "<label>" + name + "</label>" + "<br />";
word_def = $("WordDefinition", this).text();
buf += "<b>Definition:</b> " + word_def + "<br />";
buf += name + "<hr />";
});
$("#sec01").html(buf);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(ajaxOptions);
alert(thrownError);
}
});
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome! Thanks for the points!
ASKER