Ajax call in MVC
The first thing to look at is the key settings options that are available for AJAX requests:
type This is type of HTTP Request and accepts a valid HTTP verb. POST is the option illustrated in this article.
url This is the location of the resource that the request will be made to.
data This is the actual data to be sent as part of the request.
contentType This is the content type of the request you are making. The default is 'application/x-www-form-urlencoded'.
dataType This is the type of data you expect to receive back. Accepted values are text, xml, json, script, html jsonp. If you do not provide a value, jQuery will examine the MIME type of the response and base its decision on that.
Example
< script >
$( function () {
$( "button" ).click( function () {
var car = { Make: 'Audi', Model: 'A4 Avant', Colour: 'Black', Registered: 2013 };
$.ajax( {
type: "POST",
url: "/Receiver",
data: car,
datatype: "html",
success: function ( data ) {
$( '#result' ).html( data );
}
} );
});
} );
< /script >
Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
Showing posts with label Ajax call in MVC. Show all posts
Showing posts with label Ajax call in MVC. Show all posts
Subscribe to:
Posts (Atom)
Consistency level in Azure cosmos db
Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
· Azure Service Fabric is Microsoft’s Platform-as-a-Service (PaaS) and is used to build and deploy microservices-based cloud applicat...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...