请求HTML中的OData资源

2024-09-30 22:23:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我对web开发非常陌生,目前正在从事一个项目,该项目要求我从ODataURL检索数据。将来,可以从url进行查询

<html>
<body>
<script src= "{{ url_for('static', filename = 'js/odatajs-4.0.0.min.js') }}" ></script>
<script>var headers = { "Content-Type": "application/json", Accept: "application/json" };
 var request = { 
 requestUri: "http://services.odata.org/V4/TripPinServiceRW/People",
 method: "GET",
 headers: headers,
 data: null
};
odatajs.oData.request(request, function (data, response) {
    if ((response.statusCode == '200') &&
    (response.body.indexOf('}', response.body.length - 1) == response.body.length - 1) &&
    response.headers['Content-Type'] == "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8") {
    document.getElementById('msg').innerHTML += ("<div>odatajs V4 testing pass!</div>");
} else {
    document.getElementById('msg').innerHTML += ("<div>odatajs V4 testing failed.</div>");
}
}, function (err){
document.getElementById('msg').innerHTML += ("<div>odatajs V4 testing failed.</div>");}); </script>

我目前正在使用FlaskPython生成html的模板。我尝试将Olingo Javascript添加到html中以显示数据

该网页没有显示任何内容


Tags: divjsonapplicationresponserequesthtmlscriptbody