Ajax call in WordPress – unable to display the data on the page

The solution to my problem is to:

  1. Add actions and create a function in functions.php.
  2. Create an empty block in display-location.php.
  3. Append the response from jQuery.ajax in success function to previously created empty block.

I hope this will help someone in the future (final code is inside the edited question itself).

Thank you.