Use ASP. NETAJAX in PHP

Source: Internet
Author: User
Write a Service file and create a php file named EmployeeService. php. First, write this sentence and include the necessary support code: require_onceMSAjaxService.php; then define an Employee class. Four attributes are clear at a glance. Needless to say: classEmploye Ajax

Write Service files

Create a php file named EmployeeService. php. First, write this sentence and include the necessary support code:

Require_once 'msajaxservice. php ';


Then define an Employee class. The four attributes are clear 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, the EmployeeService class inherits from the MSAjaxService base class in MSAjaxService. php. Define a method to return an Employee object:

Class EmployeeService extends MSAjaxService
{
Function GetEmployee ()
{
Return new Employee (12345, "Dflying Chen", "Dflying@some.com", 1000 );
}
}


Create an EmployeeService instance and call the ProcessRequest () method of the base class to process the request:

$ TheService = new EmployeeService ();
$ TheService-> ProcessRequest ();


Success!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.