【发布时间】:2018-12-15 03:00:59
【问题描述】:
我之前发布了一个关于 yahoo 使用 jsonp 的 Auction Api 的问题
这是数组的一个sn-p。
"Result": {
"UnitsWord": [
"example1",
"example2",
"example3",
"example4",
"example5"
]
},
这是我的代码
function changeText2(){
var userInput = document.getElementById('userInput').value;
$jsonurl = "https://auctions.yahooapis.jp/AuctionWebService/V2/json/search?appid="instert-yahooidhere"-&query=" + userInput;
$.ajax({
type: 'GET',
url: ($jsonurl),
contentType: 'application/json',
dataType:'jsonp',
responseType:'application/json',
xhrFields: {
withCredentials: true
},
headers: {
'Access-Control-Allow-Credentials' : true,
'Access-Control-Allow-Origin':'*',
'Access-Control-Allow-Methods':'GET',
'Access-Control-Allow-Headers':'application/json',
},
success: function(data) {
console.log(data);
$.each(data, function (i, test) {
$('#howmany').append('<p><b>' + test["Result"]["UnitsWord"] + '</b> Was Found</p>');
});
},
error: function(error) {
console.log("Failed");
}
});
}
我想做什么 是换行
<div id="howmany">
<p><b>example1</b> products found</p>
<p><b>example2</b> products found</p>
<p><b>example3</b> products found</p>
<p><b>example4</b> products found</p>
<p><b>example5</b> products found</p>
</div>
如果我做错了什么, 请告诉我。 或者至少引导我到哪里可以找到更多关于这方面的信息。
【问题讨论】:
标签: javascript jquery json api yahoo