Wikipedia:WikiProject User scripts/Guide/Ajax: Difference between revisions
Content deleted Content added
Pathoschild (talk | contribs) m tweaks |
Pathoschild (talk | contribs) →Common problems: + no cross-server queries |
||
Line 4:
==Common problems==
* <p>AJAX programmers commonly run into problems if they don't account for AJAX's ''asynchronicity''. If you try to pop up a box with another page's content, you will almost certainly pop up a box containing <code>'''null'''</code>. This occurs because the script continued even though the query wasn't finished.</p><!--
--><p>To correct the problem, you need to use [[w:callback (computer science)|callback functions]]. Place the next portion of code after a query into a function, and call the function when the query completes. (The [[m:User:Pathoschild/Scripts/Ajax framework|AJAX framework]] makes this very easy to do.)</p>
* AJAX scripts cannot reach a page on a different server (for example, ''google.ca'' or ''en.wikisource.org'' from ''en.wikipedia.org''). This can be circumvented using a proxy on the current server, but none is available for Wikimedia user scripts.
==Code==
|