Get json data from URL
I want to display data currency value(3.8945) only from the URL: https://openexchangerates.orgapilatest.json?app_id=0277d31956db4d57af7207ca1ab782a5&symbols=MYRto my web page TextBox using jQuery.suggest me a way to do.
Json result as below:
{
"disclaimer": "Usage subject to terms: https://openexchangerates.org/terms",
"license": "https://openexchangerates.org/license",
"timestamp": 1517839199,
"base": "USD",
"rates": {
"MYR": 3.8945
}
}
I tried this way but nothing to display my text box.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JavaScript - read JSON from URL</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<form runat="server">
<asp:TextBox ID="txtRate" runat="server"></asp:TextBox>
<script>
$.getJSON('https://openexchangerates.org/api/latest.json?app_id=0277d31956db4d57af7207ca1ab782a5&symbols=MYR
', function(data) {
var Rate = 'rates: ${data.rates}'
$("#txtRate").val(Rate);
});
</script>
</body>
</form>
</html>