I am using YUI3 to do a GET request, but the event handlers aren't firing when I try to do a GET request. Comments should be logging to the console in each of the event handlers. Here is my code:
YUI({ filter: 'raw' }).use("io-xdr", "substitute", "json-parse", "node", function(Y) {
var url = "http://localhost:8000/scripts/test.php";
var output = Y.one("#container");
var cfg = {
method: "GET",
xdr: {
use: 'native'
},
on: {
start: handleStart,
success: handleSuccess,
failure: handleFailure,
}
};
var handleStart = function(id, a) {
output.set("innerHTML", "YES");
console.log("Inside of handleStart");
Y.log("a");
};
var handleSuccess = function(id, o, a) {
var results = Y.JSON.parse(o.responseText);
console.log(results.count);
console.log(results);
Y.log("b");
};
var handleFailure = function(id, o, a) {
console.log("Inside of handleFailure");
Y.log("c");
};
var obj = Y.io(
url, cfg
);
});
There aren't any errors in the console. The URL is correct.
Declare your handlers above where you define cfg. JavaScript uses hoisting, so the variables will technically be "available" though undefined at the pont you are trying to use them.
You can see this jsbin showing functionality works: http://jsbin.com/owemib/1/edit
Though with CORS it doesn't work, but it does at least log!