jquery ajax method



jquery ajax method

jquery ajax method

Link for all dot net and sql server video tutorial playlists
https://www.youtube.com/user/kudvenkat/playlists?sort=dd&view=1

Link for slides, code samples and text version of the video
http://csharp-video-tutorials.blogspot.com/2015/06/jquery-ajax-method.html

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1

In this video we will discuss how to make ajax requests using jquery ajax function.

The other methods that are available in jquery to make ajax requests are load(), get() and post(). We discussed these methods in detail in the previous sessions of jQuery tutorial video series. All these methods are wrapper methods and use ajax() method under the hood. In Visual Studio, if you right click on any of these methods and select “Go To Definition” from the context menu, you can see that these methods call ajax() method.

The wrapper methods are easier to use but they do not provide much flexibility. If you want to have complete control on configuring the ajax request use ajax() method.

Syntax of jquery ajax method
$.ajax( [ settings ] )

settings is a JavaScript object that we use to configure the Ajax request. For the list of all available options please check the jquery ajax method documentation
http://api.jquery.com/jquery.ajax/

Let us now modify the example we worked with in Part 59, to use ajax() method instead of post() method.

$(document).ready(function () {
var textBoxes = $(‘input[type=”text”]’);
textBoxes.focus(function () {
var helpDiv = $(this).attr(‘id’);

$.ajax({
url: ‘GetHelpText.aspx’,
data: { HelpTextKey: helpDiv },
success: function (response, status, xhr) {
var jQueryXml = $(response);
var textElement = jQueryXml.find(“Text”);
$(‘#’ + helpDiv + ‘HelpDiv’).html(textElement.text());
},
dataType: ‘xml’,
method: ‘post’
});
});

textBoxes.blur(function () {
var helpDiv = $(this).attr(‘id’) + ‘HelpDiv’;
$(‘#’ + helpDiv).html(”);
});
});

In our next video, we will discuss how to call an asp.net web service using jQuery AJAX and consume the XML data returned by the web service.

Comments are closed.