在.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>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以上!