jQuery 库函数 - JS & jQuery Notes

jQuery.Ajax

// 简化模式:接收 json 数据

    $.getJSON("/api/article/channel", { "guid": guid }, function (res) {
    // success function   });

// 跨域模式:接收 jsonp 数据

    $.getJSON("http://api.domain.com/api/slider?callback=?", function (res) {
    
//success });

// 跨域模式完整版:接收 jsonp 数据

    $.ajax({
        url: "http://panel.xpet.com/api/home-slider",
        type: 'GET',
        dataType: 'JSONP',
        success: function (data) {
            //success
        }
    });

服务端JSONP数据返回格式:

string.Format("{0}({1})", request["callback"], 原json返回字符串)

$.each(array, function(){})的中断

在function中,使用return false;来实现break功能,使用return true;来实现continue功能。

 

posted on 2017-08-14 11:26  呼呼net  阅读(89)  评论(0编辑  收藏  举报

导航