그래, jquery로 jsonp 피드를 가져온 다음 데이터로 작업하도록 내 위젯을 포맷하려고합니다.json/jquery 도움이 필요하십니까
나는 90 % 작업하고 있지만 <a href="">
은 내 jsonp에서 "item.url"이라는 링크의 값을 가져 오는 방법을 알 수 없습니다.
나는 "var url= $('<div>').attr("href",item.url);"
부분에 대한 코드가 누락되었음을 알고 있지만, 내 인생에서 어떻게 작동하는지 알아낼 수는 없습니다.
gv_responce = function (response) {
// we destroy the script element.
scriptElement.parentNode.removeChild(scriptElement);
//we have all the information in response variable in a json format,
//we just format the results.
for (keyItem in response.posts) {
var item = response.posts[keyItem];
var img = $('<img>').attr('src', item.thumbnail);
var div = $('<div>').append(img);
var title = $('<div>').html($.trim(item.title));
var text = $('<div>').html($.trim(item.excerpt));
var url = $('<div>').attr("href", item.url);
div.append(title);
div.append(text);
div.attr('class', 'gv');
$('#content').append(item.from_user);
$('#content').append(div);
}
}
})();
모든 것이 우리가 API를 호출로드 될 때 // ...
jQuery(document).ready(LKS.makeRequest());
의
, 당신이하는 div 무리를 만들고 일부 HTML로 채우기과상의 'HREF'속성을 설정하고 있습니다. 그것은 당신이 실제로하고 싶은 것입니까? – JohnP
div가 href의 속성을 가지고 있지 않습니다. http://www.w3schools.com/tags/tag_DIV.asp –
@Haim, HTML5에서 유효하다고 생각합니다. – JohnP