i am trying to get infobox from wikipedia services using jquery $.getJSON
function.
This is my function:
function GetInfoboxWikipedia(sTerm){
alert("Termo de pesquisa: " +sTerm);
var url="http://en.wikipedia.org/w/api.php?action=parse&format=json&page=" + sTerm + "&redirects&prop=text&callback=?";
var html = "";
$.getJSON(url,function(data){
wikiHTML = data.parse.text["*"];
$wikiDOM = $("<document>"+wikiHTML+"</document>");
alert("html: "+$wikiDOM.find('.infobox').html());
html += $wikiDOM.find('.infobox').html();
});
return html;
}
i call it like this:
result_html += GetInfoboxWikipedia(searchTerm);
result_html is what i the html element i am appending to. ALthough the alerts in the function return correctly nothing appears. i think its because the call is asynchronous. How can i have the result_html += GetInfoboxWikipedia(searchTerm)
returning the value when i enter in that part of the code?