Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it recommended to use unobtrusive AJAX with MVC 5?

I know that there is library that supports unobtrusive AJAX so I asked my father (also .net programmer) why he don't use it and his answer was very surprising for me:

"The unobtrusive AJAX (in your case jquery.unobtrusive-ajax) not recommended for use so I don't using it. I prefer manually write AJAX requests using JQuery."

I searched around the internet but I can't find place that saying that unobtrusive AJAX is not recommended for use.

So is there any problem with the usage of jquery.unobtrusive-ajax and MVC AJAX helpers? If so, Can you say what is the problem and is it fixable?

like image 394
Zilberman Rafael Avatar asked Jan 04 '14 11:01

Zilberman Rafael


People also ask

What is unobtrusive Ajax in MVC?

The idea behind Unobtrusive AJAX is that AJAX behaviour is attached to form and anchor elements via HTML5 data-* attributes, instead of binding click event handlers in script blocks. In old MVC, these attributes can be generated from Html helpers: Ajax. BeginForm and Ajax. ActionLink and then setting some AjaxOptions .

Can we use Ajax in MVC?

The MVC Framework contains built-in support for unobtrusive Ajax. You can use the helper methods to define your Ajax features without adding a code throughout all the views. This feature in MVC is based on the jQuery features. To enable the unobtrusive AJAX support in the MVC application, open the Web.

What are Ajax in ASP NET MVC 5?

It is a client-side script that communicates to and from a server/database without the need for a postback or a complete page refresh. The Ajax speeds up response time. In other words, Ajax is the method of exchanging data with a server, and updating parts of a web page, without reloading the entire page.

What is unobtrusive MVC?

Unobtrusive JavaScript is a general term that conveys a general set of guidelines or margins to the term REST. REST is nothing but the Representational State Transfer. We can explain Unobtrusive JavaScript as- it is not your particular JavaScript code that you generally use in your markup page.


1 Answers

The Unobtrusive Validation and AJAX support in ASP.NET MVC follow many best practices that enable Progressive Enhancement and are also super easy to use. The unobtrusive AJAX library (not the unobtrusive validation library) is admittedly a bit limited in functionality, but if it satisfies the requirements of the application you are writing, then by all means use it. And because the source code of it is in your app (it's JavaScript, after all), it's generally straightforward to make any updates or changes to it as you see fit.

If someone wants to write everything manually, they are welcome to write assembly code to solve all their problems. Or just etch 1's and 0's onto a DVD with a laser pointer.

like image 54
Eilon Avatar answered Sep 19 '22 13:09

Eilon