[英]get JSON data from a web-service to make a picture gallery
A web-service is available at http://www.cs.sun.ac.za/rw334/products.php ?可从http://www.cs.sun.ac.za/rw334/products.php获得网络服务? limit=12&skip=0
限制=12&跳过=0
I want to get the data in there into a Javascript array.我想将那里的数据放入一个 Javascript 数组中。 I've searched around and I think I should start like this?
我已经四处搜索了,我想我应该这样开始吗?
$.ajax({
type: "GET",
url: "http://www.cs.sun.ac.za/rw334/products.php?limit=12&skip=0",
data: {id:id, name:name,url:url},
contentType: "application/json",
dataType: "json",
success: ??
}
});
How should I continue to get this data from the .php file into a Javascript array?我应该如何继续从 .php 文件中获取这些数据到 Javascript 数组中?
product = [];
$.ajax({
type: "GET",
url: "http://www.cs.sun.ac.za/rw334/products.php?limit=12&skip=0",
dataType: "json",
success: function(data) {
$(data.products).each(function(i, products){
product[products.id] = products.name;
});
console.log(product);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.