asp.net-mvc-3model-view-controllernhibernateorchardcmsgeotargetting

Display results dynamically based on GeoLocation MVC


I am building a webpage that needs to Query the database and display events in your area based on the users GeoLocation. I've seen this done so many times now on a lot of websites. But I have never built this functionality before.

I have the GeoLocation part functioning. When you land on the page it displays your zip code. I'm not sure how to grab that Zipcode from the div and query the database immediatley.? This webpage being is built using Orchard MVC/NHibernate.

Any suggestion would be helpful.


Solution

  • It sounds like you want the entire solution, but I'm not going to go into that kind of detail.

    So I'll give you tips:

    1. Use jQuery to grab the zip code from the DOM
    2. Use jQuery to do an AJAX call to a action method in one of your controllers, passing the zip
    3. Have the controller call the DB and hydrate the results into JSON
    4. Have the controller return a JsonResult
    5. Have jQuery handle the response of the AJAX call and do something meaningful