开发者

Why callback appears on jquery ajax call?

On a test page i've got this

<script type="text/javascript">
var arreglo = [];
function parse_envivo(data) {
    if(data.length != 0) {
        alert(data.fuente);
        $.each(data, function(index, data) {
            if (jQuery.inArray(data.id, arreglo) == -1) {
                arreglo.push(data.id);
                $("#envivo > tbody:last")开发者_如何学JAVA.append("<tr><td>" + data.titulo + "</td><td>" + data.link + "</td><td>" + data.fuente + "</td></tr>");
            }
        });
    }
}
$(document).ready(function() {
    var fecha = Math.round((new Date()).getTime() / 1000);
    setInterval(function() {
        $.ajax({
            data: "fecha="+fecha,
            type: "GET",
            dataType: "json",
            url: "data.php",
            success: function(data){
                parse_envivo(data);
            }
        });
    }, 5000);
});
</script>

html

                <table cellspacing="0" cellpadding="0" id="envivo">
                    <thead>
                        <tr>
                            <th>Usuario</th>
                            <th>Acción</th>
                            <th>Título</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>

working... but when i'm trying to move it into my website (with other jquery functions)


Hey! It was a jquery validation problem. After upgrading it to 1.8 problem solved :D

Thanks alL!


Try using POST instead of GET...

May be it will work for you..


Is it possible that there is other js code calling $.ajaxSetup() ? I am wondering if there is some option set that you are unaware of... I have never used it, but I suspect crossDomain: true might have the affect you are seeing, as far as appending a callback function.


This is a quick-fix solution that I would be hesitant to use, but,

remove this line:

data: "fecha="+fecha,

and change this line

url: "data.php",

to

url: "data.php?fecha=" + fecha,
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜