简体   繁体   English

javascript或ajax actionlink

[英]javascript or ajax actionlink

I am working with mvc4 and new to working with it. 我正在使用mvc4,并且是初次使用它。 I have a question around the Ajax ActionLink. 我对Ajax ActionLink有疑问。

I have a long list of products, with each, there is an add to bag button. 我的产品清单很长,每种产品都有一个“添加到购物袋”按钮。 In the past I would use jquery to bind a click event to this button and then use javascript to make a server side request to a controller action. 过去,我将使用jquery将click事件绑定到此按钮,然后使用javascript向控制器操作发出服务器端请求。

I want all interaction to not cause a full page postback. 我希望所有互动都不会引起整页的回发。

I am wondering is it best to follow my approach with javascript or use the Ajax ActionLink? 我想知道最好是用JavaScript跟随我的方法还是使用Ajax ActionLink? What are the pros and cons of either approach? 两种方法的优缺点是什么?

Both are same. 两者都一样。

  1. Ajax ActionLink : less to write, works with conjuction Jquery un-obtrusive. Ajax ActionLink:无需编写代码,可以与结合使用Jquery兼容。 Not much control on the markup. 对标记没有太多控制。
  2. HtML Link + Jquery Ajax call : will you give full control on the click event, you can add extra options to it. HtML Link + Jquery Ajax调用:您可以完全控制click事件,也可以为其添加其他选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM