ajax call to a web service and cross-domain issues..
Is it possible to use $.ajax to call an external web service directly, or do I need to write a dot net server-side wrapper to consume the web service, then call the wrapper from jQuery ?
I have attempted a direct call as shown below, which works fine in IE but generates an error in Firefox, which I presume relates to the cross-domain scripting issue.
$.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 = "";
$(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);
}
});