嗨大家好我使用谷歌de api的书籍来阅读关于书籍的信息我打电话与URL号码的URL,这返回一个JSON我创建一个散列,我保存的数据,我想。在其他varibale保存ajax的请求
下一步如果得到这个散列值来保存在数据库..任何想法如何获得这个值,并走出去。 这是我的代码
var id = "0716604892";
var post_url = "https://www.googleapis.com/books/v1/volumes?q=isbn:";
post_url = post_url + id;
findBook("0716604892");
function findBook(elem) {
var id, post_url, request;
post_url = "https://www.googleapis.com/books/v1/volumes?q=isbn:";
id = elem;
post_url = post_url + id;
request = function(){
$.ajax({
url: post_url,
method: 'GET',
data: {
dataType: "json"
},
success: function(html, data) {
var author, hashPetName, image, title;
title = html['items'][1]['volumeInfo']['title'];
author = html['items'][1]['volumeInfo']['authors'][0];
image = html['items'][1]['volumeInfo']['imageLinks']['smallThumbnail'];
hashPetName = {
'title': title,
'author': author,
'image': image
};
},
error: function(errorThrown) {
console.log(errorThrown);
}
});
return hasBookName
};
};
elemento_save = request;
我想这elemento_save = hasBookName
任何想法!
在此先感谢
为什么你用'id = void 0'?这是没用的任何声明包含'void 0' –
什么是break;'为什么? –