Member-only story
How To Insert Ajax Result In A Text Field
In this tutorial, we are going to learn how to insert ajax results in the text field. Most of the ajax request is sent via get method but here we will use the post method. As said earlier, we will send the ajax request first and take the response from the database in JSON format.
Also Read, How to append data to dropdownlist using Jquery Ajax PHP
First, we must have the tables. Here I am using two tables, city and pin codes.
DDL information of the table ‘city’
— — — — — — — — — — — — — -
CREATE TABLE `city` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`state_id` int(10) DEFAULT NULL,
`city_name` varchar(225) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci