开发者

asp.net mvc 3 calling a controller's action using either jquery or ajax

开发者 https://www.devze.com 2023-03-23 03:34 出处:网络
I have a probl开发者_StackOverflow社区em calling an action using javascript. So, I calculate a distance between two latitudes and longitudes. Now, If that distance is greater than 100 miles I want to

I have a probl开发者_StackOverflow社区em calling an action using javascript. So, I calculate a distance between two latitudes and longitudes. Now, If that distance is greater than 100 miles I want to call "distant" action in home controller that would return different view, but if it's less I would like to stay with index action. Any ideas? Thank you!


Why can't you just do something like:

if (distance > 100) {
  $.ajax({url: 'distantURL', ...});
} else {
  $.ajax({url: 'closeURL", ...});
}

Without additional information, it's tough to give a more detailed and/or accurate answer.

EDIT: Here's a nice walk-through tutorial of loading a partial view via jQuery's $.ajax() function, which sounds like what you want to do.

0

精彩评论

暂无评论...
验证码 换一张
取 消