| Subcribe via RSS

Viagra online
XANAXadderall onlineLevitraPuppies for sale

Passing Arrays to PHP via AJAX

I've written on processing AJAX queries before but neglected discussing how to pass an array to PHP for processing. This is an example of getting all checked rows in an EXTJS grid and posting them to an awaiting PHP script.

First we have the users confirm they really want to process all checked records:

 
Ext.MessageBox.confirm('Confirm', 'Are you sure your want to email login info to all selected users?', confirmEmailUsers);
 

Now the jQuery method:

 
function confirmEmailUsers(btn){
   if(btn=='yes'){
	   var recArray=new Array();
	   var ids=new Array();
	   var recArray = mailqueueGrid.getSelectionModel().getSelections();
	   for (var i = 0 ; i < recArray.length ;i++) {
		  ids[i] = recArray[i].get('id');
	   }
	  $.ajax({
		type: "POST",
		dataType: 'json',
		url: '/cpsia/?c=form&m=processqueue',
		data: 'ids='+ids,
		success: function(msg){
			alert(msg)
		}
	  });
   }
}
 

Finally, the PHP script to processes it:

 
$ids = explode(",",$_POST['ids']);
foreach ($ids as $id) {
   echo $id .'';
}
 
Tags: , , ,

AS3 MovieClip Arrays & Loops

March 16th, 2010 | No Comments | Posted in ActionScript 3

I'm often tasked with applying the same listeners & properties to multiple MovieClips in Flash. The easiest is to store the MovieClips in an array:

 
var navButtons=[navCompanyMC,navNewsMC...];
 

Then you can simply iterate over them:

 
var i=1;
for (i in navButtons) {
  doSomethingToClip(navButtons[i]);
}
 

Sample usage:

 
public function doBuild():void {
  var navButtons=[navCompanyMC,navNewsMC...];
  var i=1;
  for (i in navButtons) {
    registerEachButton(navButtons[i]);
  }
}
function registerEachButton(clip:MovieClip):void {
  clip.buttonMode=true;
  EventManager.addEventListener(clip,MouseEvent.MOUSE_OVER,doRollOver,false,0,true,true);
  EventManager.addEventListener(clip,MouseEvent.MOUSE_OUT,doRollOut,false,0,true,true);
  EventManager.addEventListener(clip,MouseEvent.CLICK,doClick,false,0,true,true);
}
function doRollOver(e:Event):void {
  //trace(e.target.name)
  e.currentTarget.gotoAndStop('over');
}
function doRollOut(e:Event):void {
  trace(e.target.name);
  e.currentTarget.gotoAndStop(1);
}
function doClick(e:Event):void {
  trace(e.target.name);
}
 
Tags: , , ,