function getMean(word){ if(word==""|| word=="Enter a word") return; ajax = new XMLHttpRequest(); // result callback ajax.onreadystatechange = function(){ if(ajax.readyState==4 && ajax.status==200){ var massaged = ajax.responseText.replace(/^[^(]+\(|[^}]+$/g, ''), res; try { res = JSON.parse( massaged ); } catch( e ) { res = new Function( 'return ' + massaged )(); } $('#result').val(process(res)); } } // make the call var encoded = encodeURIComponent("http://www.google.com/dictionary/json?callback=process&sl=en&tl=en&restrict=pr,de&client=te&q=" + word); ajax.open("GET","proxy.php?url=" + encoded,true); ajax.send(null); } // iterates through json result object, returns word definition object function process(json_obj){ var result = { sound : null, pronunciation : null, primary_means : null }; for (var prop in json_obj){ if(prop=="primaries"){ var stuff = json_obj["primaries"][0]; // get pronunciation and sound var isa = ""; var sound; var pro = stuff["terms"]; for(var i=0;i