[英]Posting data from JQUERY API into HTML
I'm by no means an expert. 我绝不是专家。 At the company I work for, we are having an external company develop a website for us.
在我工作的公司,我们有一家外部公司为我们开发一个网站。 We sell a variety of products and would like to create an API to keep everything up to date.
我们出售各种产品,并希望创建一个API以使所有内容保持最新。 I created the API using kimonolabs and that went smoothly and it's fetching the information I want.
我使用kimonolabs创建了API,并且运行顺利,并且正在获取我想要的信息。 My question is, how do I get it to show up in divs and other tags so I can style the information.
我的问题是,如何使它显示在div和其他标签中,以便为信息设置样式。 Here is what I've got.
这就是我所拥有的。 I just need to know what to put in the comment section //do something with response.
我只需要知道在注释部分放什么//做一些响应即可。
<script>
$.ajax({
url:"https://www.kimonolabs.com/api/balbvqjq?apikey=AxJK7bN6CCfuHxT46W9WAIHV2PhIrEt4",
crossDomain: true,
dataType: "jsonp",
success: function (result) {
alert('It Works!');
//Do something with the response
},
error: function (xhr, status) {
//handle errors
}
});
</script>
I just need to know the basics to get the ball rolling. 我只需要了解使球运转的基本知识即可。
A simple tutorial For you.. 一个简单的教程给你
Suppose the result stores 假设结果存储
{
"name": "mkyong",
"age": 30,
"address": {
"streetAddress": "88 8nd Street",
"city": "New York"
},
"phoneNumber": [
{
"type": "home",
"number": "111 111-1111"
},
{
"type": "fax",
"number": "222 222-2222"
}
]
}
Then possible use cases to fetch the values are 然后可能的用例来获取值是
alert(result["name"]); //mkyong
alert(result.name); //mkyong
alert(result.address.streetAddress); //88 8nd Street
alert(result["address"].city); //New York
alert(result.phoneNumber[0].number); //111 111-1111
alert(result.phoneNumber[1].type); //fax
alert(result.phoneNumber.number); //undefined
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.