I am making a POST
web-api
call from a jQuery script, but the data is not binding. Page
is null
Jquery
$("document").ready(function(){
myTimer= setInterval( "StartTimer()", 1000);
});
function StartTimer()
{
$.ajax({
type: 'POST',
contentType: "application/x-www-form-urlencoded",
url: "/api/sitehit/LogHit/", //method Name
data: 'Page=test' ,
dataType: 'text/plain',
error: function (msg) {
alert(msg.responsetext);
}
}).fail(function () {
alert("error logging hit");
}).success(function () {
alert("success logging hit");
});
clearInterval(myTimer);
}
C# code
public class SiteHitController : ApiController
{
[HttpPost]
public void LogHit(string Page) // Page not binding
{
var c= Page; // Page is null
}
}