http://example.co/?method=get&search=hours&type=place&place_id=1&format=json
is the URL I use to make an API call. The response file has no extension and is in JSON format, like this:
[
{
"hours": {
"monday": {
"open_time": "11:00:00",
"close_time": "22:00:00"
},
"tuesday": {
"open_time": "11:00:00",
"close_time": "22:00:00"
},
"wednesday": {
"open_time": "11:00:00",
"close_time": "22:00:00"
},
"thursday": {
"open_time": "11:00:00",
"close_time": "22:00:00"
},
"friday": {
"open_time": "11:00:00",
"close_time": "23:00:00"
},
"saturday": {
"open_time": "11:00:00",
"close_time": "23:00:00"
},
"sunday": {
"open_time": "11:00:00",
"close_time": "21:00:00"
}
}
}
]
When attempting to retrieve the data using either .getJSON or .ajax methods, it does not work for me. My questions are:
- Is there another method to fetch data from a server through a URL within an API call?
- If xmlHTTPRequest() is used instead of .getJSON or .ajax, would it be as effective? If yes, how would the implementation differ?