87,990
社区成员
发帖
与我相关
我的任务
分享
<body>
<div id='content'>
<script type="text/javascript">
$(document).ready(function () {
var theme = $.data(document.body, 'theme');
var source=[];
if (theme == null || theme == undefined) theme = '';
$.get("Handler.ashx",function(json){
source=json;
});
//这是默认生成的数组,变量名称为source,我的想法是动态读取数据,就是 Handler.ashx
//但是不知道如何从后台能生成像下面这样的数据变量,再赋值给source。
// var source = [
// 'Affogato',
// 'Americano'
// ];
// Create a jqxListBox
$("#jqxWidget").jqxListBox({ source: source, width: '200', height: '250px', theme: theme });
});
</script>
<div id='jqxWidget'>
</div>
</div>
</body>
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Affogato,Americano");
}
public bool IsReusable {
get {
return false;
}
}
}
var source;
$.ajax({
type: "GET",
url: "Handler.ashx",
async: false,//设置同步
dataType: "json",//定义返回格式
success: function(json){
source = json;
}
$("#jqxWidget").jqxListBox({ source: json, width: '200', height: '250px', theme: theme });
});
$(document).ready(function () {
var theme = $.data(document.body, 'theme');
var source=[];
if (theme == null || theme == undefined) theme = '';
$.get("Handler.ashx",function(json){
$("#jqxWidget").jqxListBox({ source: json, width: '200', height: '250px', theme: theme });
});
});