我正在使用 YUI3 执行 GET 请求,但是当我尝试执行 GET 请求时事件处理程序没有触发。注释应该在每个事件处理程序中记录到控制台。这是我的代码:
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
);
});
控制台中没有任何错误。网址是正确的。