This person has a very simple translation script working on the Wiktionary API.
How would I go about modifying this to return some dictionary definitions for English words?
http://jsfiddle.net/karlb/PxfrJ/11/
function show_result(data) {
$("#result ul").text('');
$.each(data.query.pages, function(page_id, page) {
if (page.iwlinks === undefined) {
$("#result ul").append('no results');
return false; // break
}
$.each(page.iwlinks, function(i, el) {
var trans = el['*'];
trans = trans.replace('Special:Search/', '').replace('_', ' ');
$("#result ul").append('<li>' + trans + '</li>');
});
});
$("#result").fadeIn('fast');
}
function translate() {
$("#result").fadeOut('fast');
$.ajax({
url: 'http://' + $('#from').val() + '.wiktionary.org/w/api.php',
data: {
action: 'query',
prop: 'iwlinks',
format: 'json',
iwlimit: 30,
iwprefix: $('#to').val(),
titles: $('#word').val()
},
dataType: 'jsonp',
success: show_result
});
return false;
}
$('form').submit(translate);
$('#word').focus();