我使用YUI将io发送到服务器以及如何回复YUI? 这是代码:
var user = {
userName: username,
password: password,
customerId: customerId
};
var success = function (ioId, o) {
responseContent = Y.JSON.parse(o.responseText);
if (responseContent.code == 0) {
window.location = 'Home.jsp';
}
};
var failure = function (ioId, o) {
//do something
};
var cfg = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
sync: false,
data: user,
on: {
'success': success,
'failure': failure
}
};
new Y.IO().send("http://localhost:7778/web/LoginController", cfg);
重定向不起作用,我决定通过YUI重定向。感谢!!!
答案 0 :(得分:0)
var success = function (ioId, o) {
responseContent = Y.JSON.parse(o.responseText);
if (responseContent.code == 0) {
window.location = 'Home.jsp';
}
//Like this?
responseDiv.innerHTML = responseContent.yourData;
};