木子屋 Dnawo's BLOG

jQuery.ajax异步获取json/script数据示例

👤 dnawo 📅 2012-10-24 👁 5769 👍 0 💬 0 🔄 来源:本站原创
1.异步获取json数据:

$(document).ready(function(){
    $.ajax({
        url: "http://www.mzwu.com/json.asp",
        data: "t=" + new Date().getTime(),
        dataType: "json",        
        type: "post",
        async: true, //可省略
        success: function(data) {
            //todo
        },
        error: function () {
            alert("error.");
        }
    });
});

2.异步加载script:

$(document).ready(function () {
    $.ajax({
        url: "http://www.mzwu.com/script.asp",
        data: "t=" + new Date().getTime(),
        dataType: "script",
        async: true, //可省略
        error: function () {
            alert("error.");
        }
    });
});

评论(0)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 jQuery插件:Validation中success和subm… 下一篇 → ASP.NET MVC3在View中使用Session示例