Using ASP.net AJAX in PHP
Writing Service Files
Create a new php file named employeeservice.php. First write this sentence, include the necessary support code:
Require_once ' msajaxservice.php ';
then define an employee class. Four properties at a glance, needless to say:
Class Employee
{
Public $Id;
Public $Name;
Public $Email;
Public $Salary;
function __construct ($id, $name, $email, $salary)
{
$this->id = $id;
$this->name = $name;
$this->email = $email;
$this->salary= $salary;
}
}
Next is the EmployeeService class, which inherits from the Msajaxservice base class in msajaxservice.php. A method is defined to return an Employee object:
Class EmployeeService extends Msajaxservice
{
function GetEmployee ()
{
Return to New Employee (12345, "dflying Chen", "Dflying@some.com", 1000);
}
}
then create a new instance of EmployeeService and call the base class's ProcessRequest () method to process the request:
$theService = new EmployeeService ();
$theService->processrequest ();