Hi Kim,
You are mixing JS and server-side code in one file, and your example simply wouldn't work.
When the page gets rendered:
- Web server first tries to execute this line
<%= NearestSitesByLocation(Lat, Long) %>
- Then, after the page is rendered, JS is executed to pick up
$(document).ready()
event
You need to substitute it with Ajax call.
Please refer to this thread on Stackoverflow, I think it outlines pretty similar issue.