User:NoseOfCthulhu/Sandbox1

AJAX table loading User:NoseOfCthulhu/Sandbox1

AJAX table loading User:NoseOfCthulhu/Sandbox2

AJAX table loading User:NoseOfCthulhu/Sandbox1/3

AJAX notes
This section attempts to detail various mechanics of AJAX functionality (aka "Ajax") on Terraria Wiki. The featured content do not follow any specific topic or order, and is merely listing information which is assumed to be of interest.

Issues
When loading pages with AJAX, certain elements on the target pages can normally excluded by embedding them inside. This does however not always work, and often the content will be loaded anyway. This is caused by certain interfering elements that doesn't comply with AJAX. Examples of such elements are:
 * Templates:
 * 
 * 
 * 
 * 
 * 
 * Indent colon

In all these cases, the element will be loaded regardless of whether it's embedded in  or not. Additionally, interfering elements will similarly reveal non-interfering elements if the former is included in the same  as the latter.


 * Solutions:
 * Hiding interfering content with  will prevent interference. This way, info can still be present on the page in source-form.
 * (x5) can replace a colon indentation; however probably only under certain circumstances to not itself interfere with page formatting.
 * Interfering content can be turned non-interfering by placing it inside an invisible table and adding . This will however produce a tiny colored square when loaded (see top AJAX load for example).
 * It is not possible to hide this square with additional.
 * Every such table will produce a square. While a single square is hardly notable, multiple ones will form a column.
 * It is possible to use a table to make a whole article " -friendly" and then remove specified parts of it with, but this will similarly affect the loaded page's background color.
 * Being inside a table will alter the appearance of some elements, such as placement. This can bring issues to the target page itself. Table options such as  can presumably solve it.

Alignment
When a page is loaded with AJAX, the target content will usually be center-aligned. This usually doesn't cause problems if the target content is something like a template or a table, but text can appear somewhat misplaced.


 * Solutions:
 * The text can be embedded into an invisible table like above and then aligned with  where ALIGNMENT is ,  , or  . Such a table will however alter the background color of the text on the loading page.
 * Content can similarly be embedded in CONTENT . This does not cause discoloration and is arguably the best solution.

Loaded content

 * AJAX can be used to load Templates (an example being the section of Recipes). This is often a better alternative than having the loading page display the template by normal standard if the template includes a large amount of content. However, AJAX and templates do not load content in the exact same manner. AJAX will always load pages as they appear on their "own" pages while the display of templates can be manipulated with template inclusion tags. For example, a template featuring the following formatting:
















 * ...will display the following when loaded as a template on a page:
 * {| class="terraria" style="text-align:center"

! width="20px" | Nr || width="100px" | Product
 * 1 ||
 * 2 || INCLUDEONLY
 * }
 * When loaded through AJAX it will display as:
 * {| class="terraria" style="text-align:center"
 * When loaded through AJAX it will display as:
 * {| class="terraria" style="text-align:center"

! width="20px" | Nr || width="100px" | Product
 * 1 || NOINCLUDE
 * 2 ||
 * }
 * Hence, in this case, AJAX and template-function will load the content in opposite ways.
 * }
 * Hence, in this case, AJAX and template-function will load the content in opposite ways.


 * AJAX can not load AJAX-loaded content through another page. For example, if page A loads B through AJAX, then C cannot load B by loading A.
 * C can however load B if B is a template page, but only if A loads it as a.
 * AJAX can load TOC.