Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
dev:translator_coding [2011/04/10 17:40] – [Saving Multiple Items] ajlyondev:translator_coding [2011/04/20 16:52] – adding section on cross-domain ajlyon
Line 101: Line 101:
 ''Zotero.Utilities.processDocuments(url, callback, onDone, charset)'' sends a GET request to the specified URL or to each in an array of URLs, and then calls the function ''callback'' with XXXXX arguments: DOM document object, URL, and XXXX. FIXME the optional ''charset'' argument forces the response to be interpreted in the specified character set. This is approximately the equivalent of ''doGet'', except that it returns DOM document objects instead of strings. ''Zotero.Utilities.processDocuments(url, callback, onDone, charset)'' sends a GET request to the specified URL or to each in an array of URLs, and then calls the function ''callback'' with XXXXX arguments: DOM document object, URL, and XXXX. FIXME the optional ''charset'' argument forces the response to be interpreted in the specified character set. This is approximately the equivalent of ''doGet'', except that it returns DOM document objects instead of strings.
  
-**Note:** The response objects passed to the callbacks above are <a href="https://developer.mozilla.org/en/XMLHttpRequest">described in detail in the MDC Documentation</a>.+**Note:** The response objects passed to the callbacks above are [[https://developer.mozilla.org/en/XMLHttpRequest|described in detail in the MDC Documentation]].
  
 ''Zotero.Utilities.processAsync(sets, callbacks, onDone)'' can be used from translators to make it easier to correctly chain sets of asynchronous callbacks, since many translators that require multiple callbacks do it incorrectly [text from commit message, r4262]  ''Zotero.Utilities.processAsync(sets, callbacks, onDone)'' can be used from translators to make it easier to correctly chain sets of asynchronous callbacks, since many translators that require multiple callbacks do it incorrectly [text from commit message, r4262] 
Line 120: Line 120:
 <code javascript>var bibtexData = Zotero.Utilities.retrieveSource(this.bibtexLink);</code> <code javascript>var bibtexData = Zotero.Utilities.retrieveSource(this.bibtexLink);</code>
  
 +== Cross-Domain Restrictions ==
 +Note that all the above functions are affected by [[https://developer.mozilla.org/en/http_access_control|Firefox's HTTP Access Control]]. See the linked article at the Mozilla Developer Center for more details, but the gist of it is that ''Zotero.Utilities.retrieveDocument'' and ''Zotero.Utilities.processDocuments'' will not in general work when called from one domain, requesting documents from another domain. Such arrangements are actually fairly common for site index and search pages. The other functions, like ''Zotero.Utilities.doGet'', will work, but the response will be a simple text string which will usually have to be processed using regular expressions, not XPath or other DOM-based approaches.
 +
 +When such HTTP Access Control prevents an action, you will see an error like this in the error console or debug output:
 +<code>00:41:50 Translation using Test failed: 
 +         message => Permission denied to access property 'documentElement'
 +         fileName => chrome://zotero/content/xpcom/translation/browser_firefox.js
 +         lineNumber => 451</code>
 ====== Import Translators ====== ====== Import Translators ======
 ====== Export Translators ====== ====== Export Translators ======
dev/translator_coding.txt · Last modified: 2017/11/12 19:53 by 127.0.0.1