I would like to fetch the WikiText from a Wikipedia page and display it in a browser using Javascript. The following is what I currently have:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
<body>
<div id="wikiInfo"> </div>
<script>
$.get('http://en.wikipedia.org/w/index.php?action=raw&title=Dog&callback=?',
function(data) {
$("div").add(data);
alert('load performed');
});
</script>
</body>
</html>
However, this doesn’t seem to work. Eventually, I would like to be able to save the fetched wikitext to a variable as well, so any help on that would be appreciated too.
It is cross domain, so it doesn’t work… make a wiki.php and fetch “wiki.php?title=Dog” with JS…
Edited using @Tgr WikiPedia link. I also suggest parsing JSON in PHP and then outputing HTML or raw text.