views:

36

answers:

1

Hello,

My question is similiar to this question http://stackoverflow.com/questions/2223395/how-do-you-grab-an-element-from-a-remote-page-using-mootools-and-request-html

I unfortunately am not familiar with mootools at all but am being forced to use it as a number of other components on the website rely on this framework.

I am trying to grab an element from an external page and insert that into a div on my page.

In jquery this is nice and easy $('#result').load('ajax/test.html #container');

The above question grabs an element but I don't see how to insert that content into my pages div.

I also need the element to reload the content every 30sec which I have absolutely no idea how to achieve this using mooTools.

Thanks

Tim

+1  A: 
var periodical;
var myRequest = (function() {
    new Ajax('link/to/html',{
    method: 'post',
        evalScripts: false, update: $('id_of_element_to_load_contents_to'),
    onStart: $('loaderDiv').setHTML(loader)
            //^ this part just specifies an optional image to indicate loading at the loaderDiv

    }).request();
});

window.addEvent('domready',function(){
    myRequest();
    periodical = fx.periodical(30000);
});

that's how you do it for 1.11

edited: just added the function to do the ajax request every 30 seconds

i assume the reason why the call doesnt even fire is because it isnt placed inside a domready function, it does not happen like in jquery where you simply place them inside a:

$(function() {});
lock
take note that on mootools 1.11 you dont need to specify # whenever you refer to element id's using the $ function
lock
This looks very promising but as yet I havent had any luck. Firebug shows that the call isnt even firing. Is there a particular location this script should sit or am I missing something very obvious?
Tim