Skip to content

Instantly share code, notes, and snippets.

@utkarshkukreti utkarshkukreti/function.js Secret
Created Jul 12, 2011

Embed
What would you like to do?
function gsearch(term, callback) {
dump("START", term, callback)
var url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" + term;
var req = new XMLHttpRequest;
dump("END", term, callback)
req.open('GET', url, true);
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {
var reply = "Failed";
if(req.status == 200) {
var json = JSON.parse(req.responseText);
if(json.responseData.results.length > 0) {
reply = json.responseData.results[0].url + " -> " + json.responseData.results[0].content;
}
}
callback(reply);
}
};
req.send(null);
}
STARTWARNING: NS_ENSURE_TRUE(wrapper) failed: file /home/utkarsh/dev/hg/instantbird/mozilla/dom/base/nsJSUtils.cpp, line 153
nullnull[xpconnect wrapped (nsISupports, nsIClassInfo, imIConversation, purpleIConversation, nsIObserver, purpleIConvIM) @ 0xaef653e0 (native @ 0xaf1219e0)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.