Hello again. I'm trying to get the content of a page with JavaScript. At the moment, I'm using this working code:
function getContent(page) { $.get(wgScript, { title: mw.util.wikiUrlencode(page), action: 'raw', ctype: 'text/plain' }, function(data) { doSomething(data); }); }
I want to check if the page does not exist before doing anything. How can I do that? I tried adding in function(data)
if ( data.query.pages.missing === '' ) { alert('error'); return; }
or use .fail()
but with no success.