本文介绍了成功后Ajax调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个网站,在这里我们从XML文件获取信息。它工作的伟大,但现在我需要做内容的滑块。要做到这一点,我将使用的jCarousel,声称他们可以动态地加载的内容去做,通过调用回调函数。

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.

我不能,但是,做出初步AJAX负荷,当我打电话成功的功能。我究竟做错了什么?

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);
            });

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

我是不是做错了什么???或者它是一个完全diffenerent的地方,我要看看? : - )

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

推荐答案

使用hulabula代替hulabula(),或直接传递给函数的AJAX选项:

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) { /* ... */ }
});

这篇关于成功后Ajax调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 13:56