Wikipedia:WikiProject User scripts/Guide/Ajax: Difference between revisions

Content deleted Content added
Using plain jQuery: Use promises!
Using module mediawiki.api: Use promises here as well..
Line 49:
indexpageids: true,
titles: 'Wikipedia:Sandbox'
}, {)
ok:.done( function ( data ) {
var q = data.query,
id = q && q.pageids && q.pageids[0],
pg = id && q.pages && q.pages[ id ],
rv = pg && pg.revisions;
if ( rv && rv[0] && rv[0]['*'] ) {
doSomethingWithText( rv[0]['*'] );
}
}, )
err:.fail( doSomethingInCaseOfError );
} );
</source>