How to Send JavaScript Array to the AJAX using jQuery and PHP

An Array is used to store multiple values in a single variable.

This can be used to pass the group of related values as data to the $.ajax for processing and get the response.

E.g. pass all checked checkboxes values, selected values from the list.

In this tutorial, I show how you can pass JavaScript Array to an AJAX request with an example.

How to Send JavaScript Array to the AJAX using jQuery and PHP

Read more

Return JSON response from AJAX using jQuery and PHP

JSON stands for JavaScript Object Notation, it is a data-interchange format which is also been used to pass data from the server.

It is the best and most effective way when need to return multiple values as a response from the PHP script to the jQuery.

You couldn’t directly return an array from AJAX, it must have converted in the valid format.

In this case, you can either use XML or JSON format.

In the tutorial demonstration, I will return an array of users from AJAX, while return converts the array into JSON format using the json_encode() function in the PHP.

On the basis of response show data in tabular format.

Return JSON response from AJAX using jQuery and PHP

Read more

Load more results with jQuery AJAX and PHP

You can use a single load more button on your webpage to paginate the list of records.

This type of pagination is very common on websites or in mobile apps. The user must click on the load more button whenever they need to view more items.

After the click, the data will append with the existing list items.

In this tutorial, I am creating a similar type of functionality using jQuery and AJAX.

Load more results with jQuery,AJAX, and PHP

Read more

Drag and Drop File Upload with jQuery and AJAX

Drag and drop is a simple way to allow users to upload their files by dropping them into the container. Nowadays most websites allow uploading using both drag and drop and the file browse e.g. PushBullet, Facebook, SlideShare, etc.

I am using AJAX to save the file to the server which triggers when the file dropped on the target container.

In this tutorial, I show how you can implement a similar type of feature in your project and show a thumbnail when the file is successfully uploaded using jQuery AJAX and PHP.

Drag and Drop File Upload with jQuery and AJAX

Read more