I have the following Jquery in my View to check whether the Entered Username is existing or not
Code:
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnCreate").click(function () {
//debugger;
var name = $("#UserName").val(); //Value entered in the text box
var status = $("#divStatus"); //DIV object to display the status message
status.html("Checking....") //While our Thread works, we will show some message to indicate the progress
//jQuery AJAX Post request
$.post("/UserMaintenance/UserCreate", { UserName: name },
function (data) {
if (data == "true") {
status.html(name + " is available!");
} else {
status.html(name + " is not available!");
}
});
});
});
</script>
and the following in Controller
Code:
if (user.UserName != null)
{
return RedirectToAction("UserList");
}
else
{
return Json(false);
}
but in View the value of Data is showin Undefined and its showing the message "Username is not available" for even new Usernames.
From the controller the value is not passing to the View.
Anybody know how to get the value for Data in jquery's post function....help me pleaseee..