Try with this
$.post("@Url.Content("~/ControllerName/Checkuser")", { userdata: "Default2" }, function (data) {
if (data != "") {
alert("Ok")
}
});
public JsonResult Checkuser(string userdata)
{
Object ret=0;
System.Threading.Thread.Sleep(200);
var search = db.Test1.Where(x => x.name == userdata).FirstOrDefault();
if(search!=null)
{
ret=1;
return Json(ret, JsonRequestBehavior.AllowGet);
}
else
{
return Json(ret, JsonRequestBehavior.AllowGet);
}
}