phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP - AJAX : Creating Server Code That Catch GET Parameter

Tag: AJAX, javacript, DOM, CSS, server side, javascript event, Parameter, GET   Category:
post: 17 Mar 2008 read: 114


PHP AJAX Step By Step Tutorial - part 5: Now, we write code for server. It is simple. In this application, we catch GET parameter. We use switch() for detect what user want with func parameter value.

Create file named "calculation.php" within www/test/ajax. Enter following code:


<?
switch($_GET['func']){
  case "add":
    echo ($_GET['param1'] + $_GET['param2']);
	break;
	
  case "min":
    echo ($_GET['param1'] - $_GET['param2']);
	break;  
	
  case "div":
    echo ($_GET['param1'] / $_GET['param2']);
	break;  	
	
  case "mul":
    echo ($_GET['param1'] * $_GET['param2']);
	break;  	

}

?>

Now, try http://localhost/test/ajax/calculator.html. Enter values and click button.




| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
CAPTCHA - part 3 : "Are you human or ....?" (Build Your CAPTCHA)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting