WWW::Mechanize::Plugin::Ajax - WWW::Mechanize plugin that provides the XMLHttpRequest object
Version 0.05 (alpha)
use WWW::Mechanize; $m = new WWW::Mechanize; $m->use_plugin('Ajax'); $m->get('http://some.site.com/that/relies/on/ajax');
This module is a plugin for WWW::Mechanize that loads the JavaScript plugin (WWW::Mechanize::Plugin::JavaScript) and provides it with the XMLHttpRequest object.
XMLHttpRequest
To load the plugin, use WWW::Mechanize's use_plugin method, as shown in the Synopsis. (The current stable release of W:M doesn't support it; see "PREREQUISITES", below.) Any extra arguments to use_plugin will be passed on to the JavaScript plugin (at least for now).
use_plugin
The XMLHttpRequest object currently does not support asynchronous connections. Later this will probably become an option, at least for threaded perls.
Since it uses LWP, URI schemes other than http (e.g., file, ftp) are supported.
The XMLHttpRequest interface members supported so far are:
Methods: open send abort getAllResponseHeaders getResponseHeader setRequestHeader Attributes: onreadystatechange readyState responseText responseXML status statusText Event-Related Methods: addEventListener removeEventListener dispatchEvent Constants (static properties): UNSENT OPENED HEADERS_RECEIVED LOADING DONE
responseBody, overrideMimeType, getRequestHeader, removeRequestHeader and more event attributes are likely to be added in future versions.
responseBody
overrideMimeType
getRequestHeader
removeRequestHeader
This plugin requires perl 5.8.3 or higher, and the following modules:
WWW::Mechanize::Plugin::JavaScript version 0.004 or later
WWW::Mechanize::Plugin::DOM version 0.005 or later
constant::lexical
XML::DOM::Lite
HTML::DOM version 0.013 or later
Encode 2.09 or higher
And you'll also need the experimental version of WWW::Mechanize available at http://www-mechanize.googlecode.com/svn/wm/branches/plugins/
If you find any bugs, please report them to the author by e-mail (preferably with a patch :-).
XML::DOM::Lite is quite lenient toward badly-formed XML, so the responseXML property returns something useful even in cases when it should be null.
responseXML
The send method does not yet accept a Document object as its argument. (Well, it does, but it stringifies it to '[object Document]' instead of serialising it as XML.)
send
The SECURITY_ERR, NETWORK_ERR and ABORT_ERR constants are not available yet, as I don't know where to put them.
In various other ways, it does not fully conform to the spec (which I only found out about recently). It would be quicker to fix them than to list them here. (And none of the Level 2 additions are implemented.)
Furthermore, this module follows the badly-designed API that is unfortunately the standard so I can't do anything about it.
Copyright (C) 2008 Father Chrysostomos <['sprout', ['org', 'cpan'].reverse().join('.')].join('@')>
['sprout', ['org', 'cpan'].reverse().join('.')].join('@')
This program is free software; you may redistribute it and/or modify it under the same terms as perl.
WWW::Mechanize
WWW::Mechanize::Plugin::JavaScript
WWW::Mechanize::Plugin::DOM
The XMLHttpRequest specification (draft as of August 2008): http://www.w3.org/TR/XMLHttpRequest/
XMLHttpRequest Level 2: http://www.w3.org/TR/XMLHttpRequest2/
To install WWW::Mechanize::Plugin::Ajax, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Mechanize::Plugin::Ajax
CPAN shell
perl -MCPAN -e shell install WWW::Mechanize::Plugin::Ajax
For more information on module installation, please visit the detailed CPAN module installation guide.