Final Fantasy Wiki
FFWiki forum logo.png
Forums: Index > Rin's Travel Agency > Archive > AJAX, API, and wizardry

AJAX refers to page requests made after page load without loading a new page.

Imagine registering for an account and in the Username box you type in a username already in the database. If you click the Save button and the page reloads and says "An account with that name already exists", that's not AJAX. But if when you click the save button the page is not left but that message is given then it is AJAX, because it's checked the database for the user list without leaving the page. AJAX can run at any time, so some sites check whether the account exists after you've finished typing the account name, or even every time a character is typed.

If you've seen the word AJAX on wiki before it's probably from the RecentChanges. Check that box and the list of changes reloads the RC without reloading the entire page.

The monobook skin uses almost no AJAX, though Wikia uses quite a lot especially in Oasis. That preview button sends a request to the server to generate the wikitext as HTML and shows the output (which means the edit form is not reloaded so you can still use undo to go back stuff done before the preview). With link suggest the requests to the server read the database for page names starting with what you searched. Same deal with search suggest.

Another technology available is the API. "API" here refers to api.php. Bots use it, Wikia use it, and we use it in the RC and on Etymology pages (that's where we get the list of pages the etym appears on from). API queries the database, and basically allows users to read and write to the wiki database without needing to even look at a page.

So pair AJAX with the API and you get updating pages and ways of making edits that don't require going off to an editform.

I decided to start looking into ways of allowing users to edit pages without needing to understand the structure of the page. Things I'm thinking of is editing infoboxes by interacting with the infobox on the page, or adding/editing Lua data pages through a generated GUI.

As something of a proof of concept, I wrote this code which executes on this page: User:JBed/test20. You can try it yourself: wait for the page to load and click a "Vote" button.

The API requests involved: get wikitext of section (so JavaScript can edit it without needing to see the edit form), get info about current user (so it knows username/IP, and whether the user is an IP for simple (but not catch-all) validation), make edit, get HTML of section (so it doesn't have to reload the entire page to show you the result of your edit).

I am really interested in using this. One of the ways I imagine it can be used is sending bug reports. If a user finds a bug we can allow them to bring up a bug report form, they then fill in a bug report, then using details from the textbox value, details from their DOM (like their skin, browser, and OS), we can have the report be formatted and added to a dedicated bug reports page somewhere. This would be more intuitive to users than having them go to the page, click edit and fill it in full-wikitext in a specific way, and for them to remember to give specific details about their set-up.

This is just an update to inform the community on a technology the wizards designers can utilise, and so you have a better idea of just what we can do. JBed (talk) 12:55, March 5, 2015 (UTC)