|
Save 10% off all website scripts! - Enter code
SNOWBALL at checkout!
|
Remote Data in a Firefox Extension or Add-onPosted 2009-04-22 in Scripts
Displaying remote data in your custom Firefox toolbar makes a lot of neat things possible. If your Firefox add-on needs to fetch some data from another URL, it can be done easily with XMLHttpRequest. Before continuing you should read more about what XMLHttpRequest is. If you are already familiar with XMLHttpRequest then it should be a breeze to start grabbing dynamic data in your Firefox extension. If you're new to Firefox extension development like me, navigating the MDC can take some time. The documentation is great, but a few gaps needed to be filled as well. The best place to start is to read about using XMLHttpRequest in the Mozilla Developer Center. This covers pretty much everything except retrieving the data as XML. If you're forcing XML this is important since a few browsers stumble on plaintext data when you're forcing XML (although most don't). If your request is returning a valid XML datafile, we can avoid the use of the responseText and instead get a valid XML DOM object through responseXML. Here's a quick example: Sample XML Response: <?xml version="1.0" ?><root>Some data</root> Handling the XML Response: var xmldoc = httpRequest.responseXML;
var root_node = xmldoc.getElementsByTagName('root').item(0);
var node_data = root_node.firstChild.data;
The JS code above goes in the event handler for state change to 4. It simply retrieves the response as XML and gets the root tag, saving the data to node_data. Pretty simple! Note that getElementsByTagName has a few cross-browser compatibility quirks of it's own, so you may elect to parse through all elements in a different manner.
|
SearchPopular Articles
SubscribeSubscribe via RSS Stay current with Scriptalicious news and subscribe in your favorite RSS reader. Subscribe via EmailGet the latest Scriptalicious news delivered to your inbox. Tag Cloudseo guides seo scripts scriptalicious seo tools forums PageRank SEO services content development apache htaccess mod_rewrite scripts webmaster google yahoo JavaScript XMLHttpRequest php contest software website list facebook ebook pagerank bing backlink rankings tool turnkey checker alexa themes marketing tinymce wysiwyg browser rank tools legal trademark infringement mysql social web social networking advertising google plus plus one |
77 powerful SEO scripts for under $100. |
Real-time Backlink Rank Checker script. |