Ajax.ActionLink vs Html.ActionLink + Jquery.Ajax call

孤街醉人 提交于 2019-12-21 12:11:12

问题


I can call an asp.net mvc controller via Ajax.ActionLink("Get customers","GetCustomers","Customer");

I can do the same with the Html.ActionLink and a jquery ajax call.

Where is the difference?


回答1:


Where is the difference?

In the amount of code you have to write (less with Ajax.ActionLink) and the level of control you need (more with Html.ActionLink and a jquery ajax call).

So it's amount of code vs level of control and functionality needed => up to you to decide which one you need.

Both approaches are perfectly fine. The Ajax.ActionLink uses the jquery.unobtrisuve-ajax script to AJAXify the anchor behind the scenes.

Personally I always use Html.ActionLink + jQuery.




回答2:


No difference if you ask me $.ajax is what Ajax.ActionLink is using under the hood as @gdoron mentioned in his answer. Personally using $.ajax gives a more sense of control... you can manipulate more options available in $.ajax one plus point for Ajax.ActionLink is that i think it provides out of the box support of degradation if javascript is disabled never experienced it though but you can explore it...



来源:https://stackoverflow.com/questions/10277332/ajax-actionlink-vs-html-actionlink-jquery-ajax-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!