Member-only story

How To Append Data To Dropdownlist Using Jquery Ajax PHP

Bipsmedium
3 min readJul 26, 2020

--

In this tutorial, I am going to explain how to append data to the drop down list using jquery ajax php. In order to do this, we use onchange function of jquery and send the data with get() or post() method to the ajax request and take the response data using ‘JSON’. For eg:- We have a table name ‘state’ and another table name ‘city’. Now, when we select a state from the state dropdown list, we can have the list of corresponding cities according to that particular state. So, let’s start.

Here I am using two tables respectively, state and city.

Also Read, How to search data from database using ajax in PHP

DDL information of the state table
— — — — — — — — — — — — — — —

CREATE TABLE `state` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`state_name` varchar(225) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

--

--

Bipsmedium
Bipsmedium

Written by Bipsmedium

Hi, This is Biplab and I am a PHP laravel developer and other open source technologies. I am here to share my experience with the community.

No responses yet