I would like to know if my approach is efficient and correct. my code is not working though, I don\'t know why.
There are a couple changes that I'd make.
Pull the HotelQuery
function out of the ready
function.
Second all of those variables are going to be out of scope by the time you make the alert call. If you'd like them to be in scope, declare them globally (outside of your function) and set them inside the function.
var name;
function doStuff() {
name = "reggie";
}