I'm using jQuery 3.2.1. I'm trying to call API by Ajax jQuery.
I'm following an example and code like this:
(() => {
function delTest() {
$.ajax({
url: 'http://localhost:3413/api/person?ID=100',
type: 'DELETE',
dataType: 'json',
data: { "": "Sourav Kayal" },
success: function (data, textStatus, xhr) {
console.log(data);
},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
}
});
}
})();
and API
public class personController : ApiController
{
[HttpDelete]
public string Delete([FromUri] int ID, [FromBody] String name)
{
return "Delete Operation" + "ID:- " + ID + "Name:- " + name;
}
}
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
However, it's not working now.
Returns an error: 404 Not found