asp.net mvc - What are the best practices when using jQuery Ajax calls? -


I am reviewing some code for a collaborator and when there is nothing wrong with jQuery Ajax call, I would like to be more precise about what else should not be seen in the normal Ajax call for the action of ASP.NET MVC controller.

For example, in the following code:

  $ (function () {$ .ajax ({url: "/ admin / action", type: "post" , Data: ({myObjectOrParameters}), success: function (data) {warning (data);}})}};  

Is this pattern just fine, or is there other things that should be here also? Is contentType justified? What about datafilter ? Is it unnecessary because we are not using Microsoft Ajax and ".d" are not concerned about returns, should I be worried too?

What about the type ?

Is it appropriate to use it

Is it worthwhile to use it?

Is it "$ .ajaxSetup in every case, or can we clearly define our arguments every time?

Call me a man in a nutshell ...

Let me put this code in this $ .post () method I like to see i do not see any reason to use it unless you're using more elusive options in $. Ajax () Be:

  $. Post ("/ controller / action", {myObjectOrParameters}, function (data) {warning (data);});  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -