我正在尝试构建一个非常简单的工具来在我的工作中使用。我在 eBay 工作,目前可用的工具对于这项任务来说很麻烦。我们被要求比较文本和图像,以检查卖家是否没有窃取彼此的内容。我正在使用 eBay Trading API 和创建开发者帐户时提供的示例 HTML/CSS/Javascript 代码。最终我希望实现的是一个简单的页面,将两个项目的照片和描述并排显示。但是,现在我只是试图编辑给出的示例代码以显示拍卖的开始日期。
我的问题是:我正在尝试添加一个变量,该变量的值由 API 的响应确定。其中一些是在示例中提供的,但是,当我将自己var starttime = items.listingInfo.startTime
的变量添加到函数中并将变量添加到 HTML 表中时,不会显示任何数据,包括添加之前显示的数据。不幸的是,我对 javascript 的了解并不多,所以我不确定我是否正确地表达了这个问题,更不用说让我添加的语法正确了。我究竟做错了什么?
下面是示例文本,我starttime
在 HTML 表中添加了一个声明变量 ( ) 和一个
<html>
<head>
<title>eBay Search Results</title>
<style type="text/css">body { font-family: arial,sans-serif;} </style>
</head>
<body>
<h1>eBay Search Results</h1>
<div id="results"></div>
<script>
function _cb_findItemsByKeywords(root)
{
var items = root.findItemsByKeywordsResponse[0].searchResult[0].item || [];
var html = [];
html.push('<table width="100%" border="0" cellspacing="0" cellpadding="3"><tbody>');
for (var i = 0; i < items.length; ++i)
{
var item = items[i];
var title = item.title;
var viewitem = item.viewItemURL;
var starttime = items.listingInfo.startTime;
if (null != title && null != viewitem)
{
html.push('<tr><td>' + '<img src="' + pic + '" border="0">' + '</td>' +
'<td><a href="' + viewitem + '" target="_blank">' + title + '</a>' + starttime + '</td></tr>');
}
}
html.push('</tbody></table>');
document.getElementById("results").innerHTML = html.join("");
}
</script>
<!--
Use the value of your appid for the appid parameter below.
-->
<script src=http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsByKeywords&REST-PAYLOAD&keywords=iphone%203g&paginationInput.entriesPerPage=3>
</script>
</body>
</html>"