Ajax helper in ASP.NET MVC essentially provides Ajax functionality for your web applications. AJAX Helpers are used for creating AJAX enabled elements for example Ajax enabled forms and links which performs request asynchronously. when you use Ajax helper you can submit your HTML form using Ajax so that instead of refreshing the full web page only a part of it can be refreshed. you can render action links that allow you invoking action methods using Ajax. Basically AJAX Helpers are extension methods of AJAX Helper class which exists in System.Web.Mvc.Ajax namespace.
AJAX-enabled link based example:-
Here I have created a example to show how to use AJAX action link using action and controller in Asp.Net MVC.
@Ajax.ActionLink(
"Fatch Data"
,
"GetData"
,
new
AjaxOptions {UpdateTargetId =
"Data-container"
, HttpMethod =
"GET"
})
Unobtrusive AJAX in MVC?
Unobtrusive Validation and AJAX support in MVC follows best practices that enable Progressive Enhancement and also easy to use. The unobtrusive AJAX library (not the unobtrusive validation library) is admittedly a bit limited in functionality, but if it fulfill 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.
Configuration options for AJAX Helpers
Configuration options for AJAX Helpers
It is very important to know the AjaxOptions class defines properties that allow you to specify callbacks for different stages in the AJAX request life cycle. There are several properties in AjaxOptions. Now You can use these property as par different scenario and different requirements. There are following properties provided by AjaxOptions class for AJAX helpers:
Url : Specify the URL that will be requested from the server.
Confirm: Specify a message that will be displayed in a confirm dialog to the end user.When user
OnBegin: Specify a JavaScript function name which is called at the beginning of the Ajax request.
OnComplete: Specify a JavaScript function name which is called at the end of the Ajax request.
OnSuccess: Specify a JavaScript function name which is called when the Ajax request is successful.
OnFailure: Specify a JavaScript function name which is called if the Ajax request fails.
LoadingElement: Specify progress message container’s Id to display a progress message or animation to the end user while an Ajax request is being made.
LoadingElementDuration: Specify a time duration in milliseconds that controls the duration of the progress message or animation.
UpdateTargetId: Specify the target container’s Id that will be populated with the HTML returned by the
action method.
Url : Specify the URL that will be requested from the server.
Confirm: Specify a message that will be displayed in a confirm dialog to the end user.When user
clicks on OK button in the confirmation dialog, the Ajax call performs.
OnBegin: Specify a JavaScript function name which is called at the beginning of the Ajax request.
OnComplete: Specify a JavaScript function name which is called at the end of the Ajax request.
OnSuccess: Specify a JavaScript function name which is called when the Ajax request is successful.
OnFailure: Specify a JavaScript function name which is called if the Ajax request fails.
LoadingElement: Specify progress message container’s Id to display a progress message or animation to the end user while an Ajax request is being made.
LoadingElementDuration: Specify a time duration in milliseconds that controls the duration of the progress message or animation.
UpdateTargetId: Specify the target container’s Id that will be populated with the HTML returned by the
action method.
InsertionMode: Specify the way of populating the target container. The possible values are InsertAfter, InsertBefore and Replace (which is the default).
Cross Domain AJAX (CORS)?
Cross-domain requests require mutual consent between the Web page and the server. You can initiate a cross-domain request in your Web page by creating an XDomainRequest object off the window object and opening a connection to a particular domain. The browser will request data from the domain's server by sending an Origin header with the value of the origin. It will only complete the connection if the server responds with an Access-Control-Allow-Origin header of either * or the exact URL of the requesting page. By default in ASP.NET MVC, any web browsers allows AJAX calls only to our web application’s site of origin. This will allow us to prevent various security issues. In that case, you have two options: Either add CORS header "Access-Control-Allow-Origin: *" to the response (and configure the client ajax() call with dataType:"html"), or create a special JSON(P) page that delivers the same data as JSON (with padding) (and configure the client ajax() call like in the OP, with dataType:"jsonp").
If you like this post share it.. If you encounter any problems, feel free and comment below to find solution. Share Your Experience with us.
If you like this post share it.. If you encounter any problems, feel free and comment below to find solution. Share Your Experience with us.
Smartmind Online Training provides complete knowledge regarding all core concepts and it gives enough confidence about Dotnet. We can say Smartmind Online Training is the best Dotnet Training platform for freshers because here we start every concept from the ground level and we explain concepts by taking real time scenarios, so Students get good understanding about subject. Smartmind Online Training helps you to gain depth knowledge on Dotnet and it makes you ready to become a real time Software Developers
ReplyDeleteDotnet Online Training
This is very good information for knowing the dotnet basic knowledage dotnetonlinetraining
ReplyDeleteGreat Article on ASP.NET MVC
ReplyDeleteDot Net Training in Chennai | ASP.NET MVC Training | MVC Online Training | Online MVC Training India
Wow what a cool blog you have here! I am impressed. You really put a lot of time and effort into this. I wish I had your creative writing skills, progressive talent and self discipline to produce a blog like you did.
ReplyDeleteGreat information provided about MVC Training . I appreciate your work.
We have develop the apps with different versions with Visual Studio 11 Beta? Sure, you can multi-target all these versions and even plugin more targeting packs. I'll do a blog post later this week on Portable Libraries, a new version in .NET 4.5 that makes creating libraries for any CLR (including Xbox, Phone, Mono and others).
ReplyDeletedotnet training in chennai
Thanks for sharing useful information. I am giving best MVC online training
ReplyDeletebest asp.net with MVC online training
asp.net with MVC online training
online asp.net with MVC training
asp.net with MVC
After looking into a handful of the blog articles on your site, I really like your technique of writing a blog. I book marked it to my bookmark site list and will be checking back in the near future. Take a look at my website as well and let me know your opinion.
ReplyDeleteVitiligo Treatment
Psoriasis Treatment
Dry Skin Treatment
This is very good information for knowing the dotnet basic knowledage, Most of the institutes are providing asp.net with mvc online training institute in Ameerpet.
ReplyDeleteThanks for your informative article. Really useful concept.ajax helperes explained very well thank youDot Net Training in Chennai
ReplyDeleteNice article. I have suggested to my friends to go through this blog. Thank you for sharing this useful information.If you want to learn dotnet course in online, please visit below site.
ReplyDeletedotnet Online Training, dotnet course, dotnet online training in kurnool, dotnet online training in hyderabad, dotnet online training in bangalore, online courses, online learning, online education, trending courses, best career courses
Awesome Post. I was searching for such a information for a while. Thanks for Posting. Pls keep on writing.
ReplyDeleteInformatica Training institutes in Chennai
Best Informatica Training Institute In Chennai
Best Informatica Training center In Chennai
Informatica Training
Learn Informatica
Informatica course
Informatica MDM Training in Chennai
I think everything said was very logical. However, think on this, what if you added a little content?
ReplyDeleteAuthorized macbook pro service center in Chennai | Macbook pro service center in chennai | Authorized iMac service center in Chennai | iMac service center in chennai | Mac service center in chennai | iphone unlocking service in chennai
Good Post. I like your blog. Thanks for Sharing.
ReplyDelete.Net Training in Noida
very nice blogger thanks for sharing......!!!
ReplyDeleteSalesforce Training | Online Course | Certification in chennai | Salesforce Training | Online Course | Certification in bangalore | Salesforce Training | Online Course | Certification in hyderabad | Salesforce Training | Online Course | Certification in pune
The style of writing is excellent and also the content is top-notch. Thanks for that shrewdness you provide the readers! to read. I never stop myself to say something about it. You’re doing a great job. Keep it up...
ReplyDeleteVery useful blog thanks for sharing IndPac India the German technology Packaging and sealing machines in India is the leading manufacturer and exporter of I hope I will see again. You can use this for any quantum realm white jacket kind of academic writing work.
Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
Howdy, I think your blog may be having internet browser compatibility issues. When I take a look at your site in Safari, it looks fine however, when opening in IE, it's got some overlapping issues. I just wanted to give you a quick heads up! Aside from that, excellent site!
ReplyDeleteTechnology