Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax call function after success

I'm working on a site, where we get information from an XML-file. It work great, but now I need to make a slider of the content. To do this, I will use jCarousel that claims they can do it with Dynamicly loaded content, by calling a callback function.

I can't, however, make the initial ajax load, when I call a function on success. What am I doing wrong?

$(document).ready(function() {
    $.ajax({
        type: "GET",
        //Url to the XML-file
        url: "data_flash_0303.xml",
        dataType: "xml",
        success: hulabula()
    });

    function hulabula(xml) {
            $(xml).find('top').each(function() {
                var headline = $(this).find('headline1').text();
                var headlineTag = $(this).find('headline2').text();

                $(".wunMobile h2 strong").text(headline + " ");
                $(".wunMobile h2 span").text(headlineTag);
            });

            ..............

Am I doing anything wrong??? Or is it a totally diffenerent place I have to look? :-)

like image 771
curly_brackets Avatar asked May 31 '11 08:05

curly_brackets


1 Answers

Use hulabula instead of hulabula() or pass the function directly to the ajax options:

1.

$.ajax({
    type: "GET",
    //Url to the XML-file
    url: "data_flash_0303.xml",
    dataType: "xml",
    success: hulabula
});

2.

$.ajax({
    type: "GET",
    //Url to the XML-file
    url: "data_flash_0303.xml",
    dataType: "xml",
    success: function(xml) { /* ... */ }
});
like image 165
istvan.halmen Avatar answered Oct 23 '22 21:10

istvan.halmen