I am new to Google Closure library, and I am trying to simulate something similar to that of Jquery's $.ajax function. Here is what I tried and what I got in response.
The trigger is from Chrome Extensions Right click
chrome.contextMenus.create({"title": "sample_closure", "onclick": samp.myProject.fun1,"contexts":['selection']});
This triggers the fun1 function which is defined as below:
samp.myProject.fun1 = function(info,tab) {
var string_url = info.selectionText;
//String_url works fine and passed to the function below.
samp.myProject.getAjaxData(string_url);
}
The getAjaxData function is as below.
goog.require("goog.net.XhrIo");
samp.myProject.getAjaxData = function(url) {
goog.net.XhrIo.send(url, function(event) {
alert(event.target.getResponseText());
});
}
But I get this error when I call the getAjaxData function.
Error in event handler for 'contextMenus': TypeError: Cannot read property 'XhrIo' of undefined
Can anyone tell me where I am going wrong.. I checked the Argument type that need to be passed for xhrio.send function and it has string type.