I tried creating a simple asp.net web api and tried calling it using jQuery. But it throws a 404 error. Here is the web api code
public class ProductController : ApiController
{
[HttpPost]
public Product GetProductDetail()
{
Product product = new Product();
product.ProductName = "Cricket Bat";
product.ProductPrice = "100";
return product;
}
}
And here is the jQuery Ajax code:
$(function () {
$.ajax({
type: 'GET',
url: 'Controllers/ProductController/GetProductDetail',
success: function (success) {
console.log(success);
},
error: function (error) {
console.log(error);
}
});
});
GET
andPOST
but both not working... – iJade Aug 1 '14 at 8:35POST http://localhost:49826/Product/GetProductDetail 404 (Not Found)
in console – iJade Aug 1 '14 at 8:38