以json格式从api返回的数据
[
{
"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"
}
}
}
]
这是我的html
中我的localhost上的javascript var req = new XMLHttpRequest();
req.open('GET', "http://example.co/?method=get&search=hours&type=place&place_id=1&format=json", true);
req.responseType="json";
req.send(null);
我尝试过使用.ajax和.get。我只是没有正确检索数据。我认为使用XMLHTTPREQUEST将是一个更好的选择。 我的问题是 1.我如何使用XMLHTTPREQUEST来检索json数据?