I am new to APS.NET MVC WEB API programming.
So here is my problem, I created an ASP.NET WEB API project with the following code
public class ValuesController : ApiController
{
public IEnumerable<Employee> Get()
{
return new List<Employee>()
{
new Employee(){ EmpId=1,EmpName="xyz" },
new Employee(){EmpId=2,EmpName="abc"}
};
}
public Employee Get(int id)
{
return new Employee() { EmpId = id, EmpName = "xyz" };
}
}
simple right .. !!
the next thing i did was create an html file and write an ajax method to get data from web api
$(function () {
var obj = {};
$.ajax({
type: "GET",
url: "http://localhost:2797/api/values/1",
data: JSON.stringify(obj),
dataType: "JSON",
contentType: "application/json; charset=UTF-8",
success: function (data) {
alert(data.EmpName);
},
failure: function (data) {
alert("Error Occured");
}
});
});
now here is the problem that my jquery script can contact webapi because breakpoints break when the html page ever gets Refreshhed and it also returns a value, but for some unknown reason the warning message in the Success function will not be deleted . and I do not know why
Please, help
Thanks at Advance .. !!