Member-only story
How To Append Data To Dropdownlist Using Jquery Ajax PHP
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