YUI ajax json最简单的写法
YUI().use("node", "io", "json-parse", function(Y) {
function handleSuccess(ioId, o) {
console.log('-------------' + o.responseText) ;
var inboxString = o.responseText;
/[^}{]+?unread[^}{]+?(\d+)[^{}]+?folderId[^\d]+?2/.test(inboxString) ;
console.log("----------------aaaaaaaa------" + RegExp.$1);
var unreadNumNew = RegExp.$1;
Y.JSON.parse(o.responseText, function(k, v) {
// console.log('-----------key---' + o + "-------value---" + v) ;
});
var unreadNum = Y.one("#folder-2 .unreadCount").get("innerHTML");
if(unreadNum) {
unreadNum = unreadNum.replace(/[^0-9]/g,'');
}
if(unreadNumNew == unreadNum) {
alert('--------aaa--------');
}
else {
alert('---------bbbbb----------');
}
}
function handleFailure() {
console.log('--------------') ;
}
var cfg = {
on:{
success:handleSuccess,
failure:handleFailure
},
method: "POST",
data: ""
};