getElementsByClassName has been deprecated due to conflicting with
modern browser's which support this method natively.
http://prototypejs.org/api/element/getElementsByClassName
-justin
function swap_rand_image() {
var url = '/path/to/random_image_ajax.php';
new PeriodicalExecuter(function() {
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport) {
Effect.Fade('random_image');
Effect.Appear.delay(2,'random_image');
$('random_image').writeAttribute('src',transport.responseText);
},
onFailure: function(transport) {
alert('This did not work');
}
});
}, 5);
}
Technically, this works, but it's changing the src of $
('random_image') before Effect.Fade is finished. So the logical
change (to me anyway) would be something like:
... onSuccess: function(transport) {
Effect.Fade('random_image');
$
('random_image').writeAttribute.delay(2,'src',transport.responseText);
Effect.Appear.('random_image').defer();
},...
Or possibly:
... onSuccess: function(transport) {
Effect.Fade('random_image');
Effect.Appear.delay(2,'random_image');
$
('random_image').writeAttribute('src',transport.responseText).defer();
},...
But neither of those works. The first throws a "element.setAttribute
is not a function" error, ref. line 1803 in prototype.js. The second
doesn't seem to make any difference on anything at all.
Any thoughts / ideas?
--Josh
Try:
Element.writeAttribute.delay(2, 'random_image', 'src', transport.responseText);
-justin
Effect.Fade('random_image',{afterFinish:function(){$
('random_image').src=transport.responseText}});
Effect.Appear.delay(2,'random_image');
--Josh
On Aug 14, 2008, at 12:27 PM, Diodeus wrote:
>
> Maybe this will work:
>
> Effect.Appear('random_image',{afterFinish:function(){$
> ('random_image').src=transport.responseText}});
>
>
> On Aug 14, 1:17 pm, Josh Carroll <j...@infinivert.com> wrote:
>> I'm trying to use AJAX to randomly shuffle through a set of photos.
>> My back-end PHP works, fine, but I'm having a timing issue with the
>> effects. Here's my code as it is at present:
>>
>> function swap_rand_image() {
>> var url = '/path/to/random_image_ajax.php';
>> new PeriodicalExecuter(function() {
>> new Ajax.Request(url, {
>> method: 'get',
>> onSuccess: function(transport) {
>> Effect.Fade('random_image');
>> Effect.Appear.delay(2,'random_image');