$(document).ready(function () { var value = getParmsVals()[\"search\"]; $.getJSON(\'/api/search/GetQuestionByKey/\' + value, function (jsonData) { $(
You can also put your variable on the object and use .bind(), like so:
.bind()
this.fullname = "default"; $.getJSON('/api/search/GetUserById/' + userId, function (jsonData) { this.fullname = jsonData.firstname + " " + jsonData.lastname; }.bind(this));