How to send GET and POST AJAX request with JavaScript

AJAX is a web de­velopment technique­ that facilitates the exchange­ of data between the­ website visible on a use­r’s browser and its server-side­ database. This enables se­amless communication for optimal performance and use­r experience­.

JavaScript libraries or frame­works are commonly utilized by people­ to conveniently transmit AJAX reque­sts. Although it’s essential to recognize­ the significance of transmitting AJAX reque­sts with plain JavaScript as well.

To communicate with the server, use an object called XMLHttpRequest. It helps in sending and receiving data between the client-side and server-side.

In this tutorial, I show how you can send GET and POST AJAX requests with JavaScript and handle the request with PHP.

How to send GET and POST AJAX request with JavaScript

Read more

How to Send AJAX request with CSRF token in CodeIgniter 3

Cross-Site Request Forgery (CSRF) is a way to trick the server that a request sent to it is legitimate while it actually is an unauthorized attempt.

In CodeIgniter, CSRF protection is not enabled by default.

If it is been enabled then CodeIgniter generates a hash for each active user and this is used to verify the request.

Require to send the hash with the AJAX request otherwise, it gives an error – “The action you have requested is not allowed.”.

In this tutorial, I show how you can enable CSRF protection and regenerate hash for the next AJAX request and pass hash in AJAX request in the CodeIgniter project.

How to Send AJAX request with CSRF token in CodeIgniter 3

Read more

Create Treeview with jsTree plugin and PHP

If you already managing the relationship between parent and child items using a separate field then it is easier to create a hierarchical structure.

With the use of a jsTree plugin, this will be created in less time.

jsTree is a jQuery plugin that creates a hierarchical data structure using JSON data.

It allows setting icon of a node, by default open, disable a node and set it selected while initializing, etc.

In this tutorial, I show how you can make a tree structure of MySQL data using jsTree plugin and PHP.

Create treeview with jsTree plugin and PHP

Read more

How to add Download Link in Dropzone – PHP

Dropzone is easy to set up on the page and upload files using Drag & Drop or file browse.

File preview display after file upload.

It allows you to add or remove file link using addRemoveLinks option but there is no option for adding a Download link.

In this tutorial, I show how you can add a download link with file thumbnail in the Dropzone container with jQuery and PHP.

How to add Download Link in Dropzone – PHP

Read more