first you should know why we are using ajax. Ajax is used to create dynamic and fast web pages. Ajax allows web pages to update asynchronously by exchanging a small amount of data with the server in the background. means it is possible to update a part of web page without reloading the whole page.
To send data using ajax we will first create html content having form element. after that we will write jquery and ajax code to send data to a specific url and we will get response from that url and we will show that response in our page.
First we will create one file called jqueryform.php and write code for form content and jquery code.

after creating above file we create indexform.php file .

in the above indexform.php file we are verifying username and password and if matches are correct return JSON response as an array with value 1 and return JSON response 0 if matches are not correct.
Execute above files: run jqueryform.php file

after putting values in it we will get response.

thanks for reading……