程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> json-$.getJSO求大神幫忙寫下ASP頁面代碼 小弟不勝感激

json-$.getJSO求大神幫忙寫下ASP頁面代碼 小弟不勝感激

編輯:編程綜合問答
$.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}])

最佳回答:


jsonp其實就是一段可以執行的js代碼,獲取回調函數名稱輸出符合js語法的語句即可

 cb=request.querystring("jsoncallback")'獲取回調函數名稱
data=""
'讀數據組合成回調需要的json數據格式,賦值給data變量

response.write cb&"("&data&")"'輸出js代碼
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved