[HTML_AJAX-devel] Best way to do AJAX

superfly brachycera at gmail.com
Wed Jan 16 07:58:46 MST 2008


hey lewis!

first see the examples how to setup the PEAR_AJAX server.php and to start
the class. when you got this, you should end up with a class you start via
the server.php. in this class you can put functions to interact with your
form. i show you an example how i made this for a project from myself...

in this func a user uses a radiobutton so re-sort the search results

class ajaxclass {
	
	function ajaxclass(){
	}

function updateorder($order, $pageID){
		
		if(!empty($_SESSION['query'])){

			require_once 'HTML/AJAX/Action.php';
			$objAction =& new HTML_AJAX_Action();
			
			if($order=='zuname'){
				$_SESSION['query']['order'] = 'zuname';				
			}
			
			if($order=='company'){
				$_SESSION['query']['order'] = 'company';
			}
			
			if($order=='lastEdit'){
				$_SESSION['query']['order'] = 'lastEdit';
			}
			
			
			if($_SESSION['query']['output']=='adressen'){
				$output = utf8_encode(queryOutputAdresses($_SESSION['query'],$pageID));
			}else{
				$output = utf8_encode(queryOutputMarketing($_SESSION['query'],$pageID));
			}
			
			$objAction->assignAttr('result', 'innerHTML', $output); // 'result' is
the ID of an html element
			return $objAction;
		}
		
	}


on the HTML side i call this func with:
onclick="ajaxclass.updateorder('company','$pageID');"

and the ajax output goes to <div id="result></div>

in the header area i got 
<header>
<script type="text/javascript"
src="server.php?client=all&amp;stub=ajaxclass"></script>
 <script type="text/javascript">var remote = new ajaxclass({});</script>
</header>


sorry my english is not the best and this example might not be perfect
either, but maybe you get a glimpse how to use PEAR_AJAX

have fun, 
superfly





standerby wrote:
> 
> Hi,
> 
> I am working on a web page, which has check box, radio button, slider,
> etc. What I want to accomplish is to display some data retrieved from
> database using the criteria enforced by those controls. I am using MDB2
> for database accessing and it works great. My question is what method I
> should use for HTML_AJAX to interactive with customer. For instance if a
> customer check a checkbox it will make a query to database and update the
> content div.
> 
> Thanks,
> Lewis
> 
>        
> ---------------------------------
> Never miss a thing.   Make Yahoo your homepage.
> _______________________________________________
> Html_ajax-devel mailing list
> Html_ajax-devel at lists.bluga.net
> http://lists.bluga.net/mailman/listinfo/html_ajax-devel
> 
> 

-- 
View this message in context: http://www.nabble.com/Best-way-to-do-AJAX-tp14744756p14881479.html
Sent from the HTML_AJAX Dev/Support mailing list archive at Nabble.com.



More information about the Html_ajax-devel mailing list