What I am trying to do is: user gets pick date range and clicks submit. Then the response from the API goes into a table format.
<!DOCTYPE html>
<html>
<head>
<title>main jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="main.js"></script>
</head>
<body>
<div>
<form>
Enter a date after 2015-01-01:
<input type="date" id="startDate" min="2015-01-01" max="2017-01-01"><br><br>
Enter a date before 2017-01-01:
<input type="date" id="endDate" min="2015-01-01" max="2017-01-01"><br><br>
<input type="button" id="btn" value="Submit" />
</form>
<p><strong>Note:</strong> type="date" only works on chrome</p>
<table style="width:100%" id="table">
<tr>
<th>Date</th>
<th>Price</th>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
<div id="price"></div>
</div>
</body>
</html>
$(document).on("click","#btn",function() {
var startDate = $("#startDate").val();
var endDate = $("#endDate").val();
var Url = "https://api.coindesk.com/v1/bpi/historical/close.json?start=" + startDate + "&end=" + endDate;
console.log(typeof(startDate));
console.log(typeof(endDate));
console.log(Url);
$.ajax({
url: Url,
type:"GET",
success: function(response) {
// I do not know what to do in my success, cannot find a
// link to help me either. Maybe I googling incorrectly?
},
error:function(error){
console.log('Error ${error}');
}
})
})
This is what my console shows. I cannot figure out what i need to put int he "success" portion of my ajax to successfully get my response. If someone can point me in the right direction I would truly appreciate it.
string
main.js:7 string
main.js:9 https://api.coindesk.com/v1/bpi/historical/close.json?start=2016-12-06&end=2017-01-01
main.js:18 Error ${error}