Benutzer:Bernardissimo/Multi: Unterschied zwischen den Versionen
Aus Stupidedia, der sinnfreien Enzyklopädie!
Zeile 1: | Zeile 1: | ||
− | <div class=" | + | <div class="parseJS"><nowiki> |
− | < | + | $('<input type="button" value="Klick" />').prependTo('#bodyContent').click(function(){ |
+ | $.ajax({ | ||
+ | url: 'http://www.stupidedia.org/api.php', | ||
+ | dataType: 'json', | ||
+ | type: 'get', | ||
+ | data: { | ||
+ | format: 'json', | ||
+ | action: 'query', | ||
+ | prop: 'info|revisions', | ||
+ | indexpageids: true, | ||
+ | rvprop: 'timestamp|content', | ||
+ | titles: 'Mann' | ||
+ | }, | ||
+ | success: function( data ) { | ||
+ | if ( 'error' in data ) { | ||
+ | alert( 'API Error ' + data.error.code + '. ' + data.error.info ); | ||
+ | } else { | ||
+ | var content = data['query']['pages'][data['query']['pageids']['0']]['revisions']['0']['*']; | ||
+ | $('#bodyContent').prepend('<textarea>'+content+'</textarea>'); | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | return false; | ||
+ | }); | ||
+ | |||
</nowiki></div> | </nowiki></div> |
Version vom 6. Dezember 2011, 00:00 Uhr
$('<input type="button" value="Klick" />').prependTo('#bodyContent').click(function(){
$.ajax({
url: 'http://www.stupidedia.org/api.php',
dataType: 'json',
type: 'get',
data: {
format: 'json',
action: 'query',
prop: 'info|revisions',
indexpageids: true,
rvprop: 'timestamp|content',
titles: 'Mann'
},
success: function( data ) {
if ( 'error' in data ) {
alert( 'API Error ' + data.error.code + '. ' + data.error.info );
} else {
var content = data['query']['pages'][data['query']['pageids']['0']]['revisions']['0']['*'];
$('#bodyContent').prepend('<textarea>'+content+'</textarea>');
}
}
});
return false;
});