layer .net中使用

來源:互聯網
上載者:User

標籤:

在.net中使用layer得用ajax來請求一般處理常式來得到想要的json資料,直接上代碼

html:

<head runat="server">    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    <title>layer</title>    <script src="layer/jquery-1.9.1.min.js"></script>    <script src="layer/layer.min.js"></script>    <script src="layer/extend/layer.ext.js"></script></head><body>    <div style="width: 100%; height: 100%; text-align: center;">        <div id="testMaxmin" style="width: 100px; height: 100px; background-color: #808080"></div>        <script>            $(‘#testMaxmin‘).on(‘click‘, function () {                $.layer({                    type: 2,                    maxmin: true,                    title: ‘網路電視‘,                    area: [‘580px‘, ‘350px‘],                    iframe: {                        src: ‘http://t.cn/zW9SbfS‘                    }                })            });        </script>        <div id="testPhotos" style="width: 100px; height: 100px; background-color: #ff6a00">            </div>        <script>            var photos;            $(‘#testPhotos‘).on(‘click‘, function () {                //判斷是否已經請求過相簿,已請求過,則直接讀取快取資料                if (photos) {                    layer.photos({                        html: ‘‘, //如果此處傳入html值,則右側地區會顯示,不傳則不顯示                        json: photos                    });                } else {                    layer.load();                    $.ajax({                        url: "handler.ashx",                        type: "post"                    }).done(function (da) {                        json = JSON.parse(da);                        photos = json;                        layer.photos({                            html: ‘‘, //如果此處傳入html值,則右側地區會顯示,不傳則不顯示                            json: json                        });                        layer.closeLoad()                    });                }            });        </script>    </div></body>

 handler.ashx

public void ProcessRequest(HttpContext context)    {        JavaScriptSerializer jss = new JavaScriptSerializer();        context.Response.ContentType = "text/plain";        string data = "{\"status\": 1,\"msg\": \"\",\"title\": \"hahahaha\",\"id\": 8,\"start\": 0,\"data\": [{\"name\": \"qwe\",\"pid\": 109,\"src\": \"../images/1.jpg\",\"thumb\": \"\",\"area\": [638,851]},{\"name\": \"weq\",\"pid\": 110,\"src\": \"../images/2.jpg\",\"thumb\": \"\",\"area\": [638,851]}]}";        context.Response.Write(data);    }

 圖片地址什麼的可以自己改,一定注意要引用js,jquery要1.8以上!

 

layer .net中使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.