How do I access an object returned from the database with Javascript
This function is called from Javascript
function searchUser() {
var userName = document.getElementById('UserName').value
$.post("SearchForUser", { userName: userName }, function (UserInfo) {
UserInfo; //How to access the returned UserInfo properties?
});
}
I Use this code to get the UserInfo from the database
public UserInfo SearchForUser(string userName)
{
string password = "nicola";
using (FormValueEntities db = new FormValueEntities())
{
//Query the database for the user
UserInfo userInfo = new UserInfo();
userInfo = db.UserGet(userName, password).FirstOrDefault();
return userInfo;
}
}
The UserInfo has the Following properties : UserName, UserPassword and Description