Code Samples

We will see few code samples here. You can get the idea to work with fakeAPIs of request methods GET, POST, PUT / PATCH, and DELETE.

A hosted REST-API ready to respond to your AJAX requests.
The APIs are CORS enabled, so you can make requests right from the browser, no matter what domain, or even from somewhere like JSFiddle or JSBin.

PHP cURL is a library that is the most powerful extension of PHP. It allows the user to create the HTTP requests in PHP. cURL allows the user to send and receive the data through the URL syntax. In this sample examples of PHP we used PHP - cURL concept.
Here, sample codes uses routes with http request methods are of GET, POST, PUT, PATCH, DELETE.

There are several modules (Employees, Projects, Messages, Albumns, and Photos) in fakeAPI server to work for dummy data.
Here, in code samples we worked with employee module.

GET

Get list of employees (PHP - cURL) from fakeAPIs.

Code Snippet

Output

View Source

POST

Save an employee data (PHP - cURL) using fakeAPIs.

Code Snippet

Output

View Source

PUT

Update employee's data By employee ID (PHP - cURL) using fakeAPIs.

Code Snippet

Output

View Source

PATCH

Update employee's data By employee ID (PHP - cURL) using fakeAPIs.

Code Snippet

Output

View Source

DELETE

Delete employee data By employee ID (PHP - cURL) using fakeAPIs.

Code Snippet

Output

View Source

AJAX allows web pages to be updated asynchronously by exchanging data with a web server behind the scenes. The ajax() method in jQuery is used to perform an AJAX request or asynchronous HTTP request.
Here, sample codes uses routes with http request methods are of GET, POST, PUT, PATCH, DELETE.

There are several modules (Employees, Projects, Messages, Albumns, and Photos) in fakeAPI server to work for dummy data.
Here, in code samples we worked with employee module.

GET

Get list of employees (jQuery - Ajax) from fakeAPIs.

Code Snippet

Output

View Source

POST

Save an employee data (jQuery - Ajax) using fakeAPIs.

Code Snippet

Output

View Source

PUT

Update employee's data By employee ID (jQuery - Ajax) using fakeAPIs.

Code Snippet

Output

View Source

PATCH

Update employee's data By employee ID (jQuery - Ajax) using fakeAPIs.

Code Snippet

Output

View Source

DELETE

Delete employee data By employee ID (jQuery - Ajax) using fakeAPIs.

Code Snippet

Output

View Source