开发者社区> 问答> 正文

$.getJSO求大神帮忙写下ASP页面代码 小弟不胜感激

var ghost = window.location.hostname+":2258";
 function Guard() {
 this.Users = new Array();
 this.GetCount = function () { return this.Users.length; }
 this.FindObject = function (name) { var u = null; $.each(this.Users, function (i, v) { if (v.m_Name == name) { u = v; return false; } }); return u; }
 this.GuardUserObject = function (m_Name, n_Name, n_Gride, g_Port, g_Toname, g_Experience, IsMG, IsGuard) { this.m_Name = m_Name; this.n_Name = n_Name; this.n_Gride = n_Gride; this.g_Port = g_Port; this.g_Toname = g_Toname; this.g_Experience = g_Experience; this.IsMG = IsMG; this.IsGuard = IsGuard; }
 this.SortDesc = function () { this.Users = this.Users.sort(function (a, b) { return b.g_Experience - a.g_Experience; }); }
 this.SortAsc = function () { this.Users = this.Users.sort(function (a, b) { return a.g_Experience - b.g_Experience; }); }
 this.RemoveAll = function () { for (var i = 0; i < this.GetCount(); i++) { delete this.Users[i]; } this.Users.length = 0; }
 this.RefreshUsers = function (json) { this.RemoveAll(); for (var i = 0; i < json.length; i++) { if (json[i].m_Name.indexOf("*") == 0 && (json[i].IsMG || (json[i].IsGuard && json[i].g_Port == parent.roominfo.Port))) { var um = new this.GuardUserObject(json[i].m_Name, json[i].n_Name, json[i].n_Gride, json[i].g_Port, json[i].g_Toname, json[i].g_Experience, json[i].IsMG, json[i].IsGuard); this.Users[this.GetCount()] = um; this.SortDesc(); } } }
 this.GetUserTypeInfo = function (name) { var outcolor = ""; var incolor = ""; var imgurl = ""; var title = ""; var user_type = 0; var u = this.FindObject(name); if (u != null) { if (u.IsMG) { user_type = u.n_Gride + 3; imgurl = "http://" + ghost + "/images/yy/noble/icon_noble" + u.n_Gride + ".png"; title = u.n_Name; } else if (u.IsGuard) { user_type = parseInt(u.g_Experience); imgurl = "http://" + ghost + "/images/yy/guardian/guardian_0" + parseInt(u.g_Experience) + ".png"; title = "守护"; } return { "user_type": user_type, "outcolor": outcolor, "incolor": incolor, "imgurl": imgurl, "title": title }; } else { return null; } }
 }
 var Guard_Json = null;
 $(document).ready(function () { $.getJSON("http://www.abc.com/0.asp?jsoncallback=?", { type: "ALL", port: parent.roominfo.Port }, function (data) { Guard_Json = new Guard(); Guard_Json.RefreshUsers(data); }); });
这个是结果ASP页面具体该如何写呢
jQuery1709215810747113315_1419650668218([{"m_Name":"*test22","n_Name":"神","n_Gride":3,"g_Port":9999,"g_Toname":"*test44","g_Experience":1.0,"IsMG":true,"IsGuard":false},{"m_Name":"*兮兮","n_Name":"守","n_Gride":4,"g_Port":0,"g_Toname":"","g_Experience":0.0,"IsMG":true,"IsGuard":false}])

展开
收起
杨冬芳 2016-07-04 16:21:51 2430 0
1 条回答
写回答
取消 提交回答
  • IT从业

    jsonp其实就是一段可以执行的js代码,获取回调函数名称输出符合js语法的语句即可

     cb=request.querystring("jsoncallback")'获取回调函数名称
    data=""
    '读数据组合成回调需要的json数据格式,赋值给data变量
    
    response.write cb&"("&data&")"'输出js代码
    
    2019-07-17 19:50:51
    赞同 展开评论 打赏
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载