$.getJSO求大神帮忙写下ASP页面代码 小弟不胜感激 -问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

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

杨冬芳 2016-07-04 16:21:51 1640
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}])
云服务器登录 云服务器设置
分享到
取消 提交回答
全部回答(1)
  • 杨冬芳
    2019-07-17 19:50:51

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

     cb=request.querystring("jsoncallback")'获取回调函数名称
    data=""
    '读数据组合成回调需要的json数据格式,赋值给data变量
    
    response.write cb&"("&data&")"'输出js代码
    
    0 0
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

相似问题
最新问题