Thursday, August 11, 2011

Ajax


		$.ajax({
			url: "/inbox/newresults", 
			async: true, 
			dataType: 'json',
			data: data,
			timeout: 3000,
			success: function(json) {	
    	        if(json == null || json.currenttime == undefined){
    	        	return;
    	        }
    	        
    	        //json.count=Math.ceil(Math.random()*100);
    	        
    	        if(json.count > 0 && json.count != monitor.numOfNewResults ){
		        	monitor.lastCheckingTime = json.currenttime;
		        	monitor.message=_("Vous avez %1 nouveaux résultats")
		        		.replace('%1',''+json.count+'');
		            document.title = document.title.replace(/\s+\(\d+\)$/,'')+' ('+json.count+')';  
		        }

		        monitor.refresh();
		        monitor.numOfNewResults = json.count;
			}
		});


public function action_availableSerieObjectTypes(){
		
		$this->auto_render=false;
		$types = stats\Chart::getAvailableChartTypes();

		// translate
		foreach($types as $k=>$v){
			$types[$k]=_($v);
		}
		
		$this->request->response = json_encode(array('serie_object_types'=>$types));
	}



Reference: 

No comments:

Post a Comment