I have ASP.NET MVC5 project in which i am setting session value in controller using setSession() which is userId. Then i need to retrieve or get that value in .js file (and set it to TextBox)
but can not get that value in .js file.
following is my .js file code
function populateUser() {
debugger;
$.ajax({
type: "GET",
url: '/UserProfile/SetSessionValues',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (data) {
if (data) {
var user = $.session.get("UserName");
$("#txtUserName").val(user);
}
},
error: function (msg) {
alert("Error :" + msg.responseText);
},
});
}
datauserId? On the client or on the server? If it is at the client, show us the code.