var Model= Backbone.Model.extend({
url: "server.php",
name:'sasha',
time:'now',
validate:function(attrs, options) {
if (attrs.rand >2) {
console.log('stop');
debugger;
}
}
})
var model=new Model;
model.on("invalid", function(model, error) {
console.log('invalid');
debugger
});
setInterval(function(){
model.fetch();
model.save()
},4000
);
我想过滤来自服务器的数据。 我有服务器:
$arr = array('a' => 1, 'time' =>date('h:m:s'),rand=>rand()*9);
echo json_encode($arr);
萤火虫没有错误!