Last active
December 19, 2015 18:19
-
-
Save ramons03/5997796 to your computer and use it in GitHub Desktop.
Parse a json result from asp MVC controller and set a variable in javascript with an attribute from the json object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getData(url) { | |
var data; | |
$.ajax({ | |
async: false, //thats the trick | |
url: url, | |
dataType: 'json', | |
success: function (response) { | |
data = response; | |
} | |
}); | |
return data.JsonAttribute; | |
} | |
var jsVar = getData('@Url.Action("getJson", "Controller")'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment