就是写了一个一般处理程序,jquery版本1.4.2。每次调用只有第一次有返回结果,后面就都没有了,不知道是怎么回事。
一般处理程序代码:
namespace JD2011.SST.Web
{
/// <summary>
/// GetInfo 的摘要说明
/// </summary>
public class GetInfo : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string action = context.Request["action"];
{
if(action=="GetSourceMovie")
{
string strSourceType = context.Request["SourceType"];
string strSourceFormat = context.Request["SourceFormat"];
var adapter = new JD2011.SST.BLL.Source();
string strName="TOP 6 Source.SourceId,SourceName,UserName,SourceUrl,COUNT(1) as times ";
string strWhere= "UserInfo,Source,SourceType,SourceCollect ";
string strCondition= "Source.SourceId=SourceCollect.SourceId and Source.UserId=UserInfo.UserId and Source.SourceFormat='" + strSourceFormat + "'and SourceTypeName='" + strSourceType + "' and Source.SourceTypeId=SourceType.SourceTypeId group by SourceName,UserName,Source.SourceId,SourceUrl";
var data= adapter.GetSpecialList(strName,strWhere,strCondition);
List<StudySource> list = new List<StudySource>();
foreach(DataRow row in data.Tables[0].Rows)
{
list.Add(new StudySource()
{
SourceID=Convert.ToInt32(row[0]),
SourceName=row[1].ToString(),
UserName=row[2].ToString(),
SourceUrl=row[3].ToString(),
times=Convert.ToInt32(row[4])
});
}
JavaScriptSerializer jss = new JavaScriptSerializer();
context.Response.Write(jss.Serialize(list));
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
public class StudySource
{
public int SourceID { get; set; }
public string SourceName { get; set; }
public string UserName { get; set; }
public string SourceUrl { get; set; }
public int times { get; set; }
}
}
js调用代码
clickFormat('视频')
function changeFormatColor(formatName, colorName, fontColor) {
varFormat = document.getElementById(formatName);
varFormat.style.backgroundColor = colorName;
varFormat.style.color = fontColor;
}
function clickFormat(id) {
changeFormatColor('文档', '#0099cc', 'White');
changeFormatColor('视频', '#0099cc', 'White');
changeFormatColor('编码', '#0099cc', 'White');
changeFormatColor(id, '#f2f2f2', '#515151');
// sqlSuorceFormat = ' Source.SourceFormat = ' + id + " ";
document.getElementsByName('dataInfo').value = id;
action=GetSourceMovie&SourceFormat="+id+"区&SourceType="+ sqlSourceType, false);
$(function () {
$.post("GetInfo.ashx", { "action": "GetSourceMovie", "SourceFormat": id + "区", "SourceType": sqlSourceType},
function (data, status) {
if (status == 'success') {
alert(data);
var sourceData=$.parseJSON(data);
for (var i = 0; i < sourceData.length; i++) {
var source = sourceData[i];
alert(source.SourceName);
}
}
});
});
}
第一次运行截图:
后面运行的截图
好像在后面运行的时候
var data= adapter.GetSpecialList(strName,strWhere,strCondition);这里没有从数据库取到数据
GetSpecialList(strName,strWhere,strCondition); 第二次的时候 看看这些参数是否取到了?
已经解决了,是我数据传错了