var hits = function (id) { this.id = id; this.type = "getnewshits()"; this.callmethod = "getnewshits()"; } hits.prototype = { getnewshits: function () { this.type = "getnewshits()"; this.callmethod = "getnewshits()"; this.gethitsajax(); }, getproducthits: function () { this.type = "getproducthits()"; this.callmethod = "getproducthits()"; this.gethitsajax(); }, getcaseshits: function () { this.type = "getcaseshits()"; this.callmethod = "getcaseshits()"; this.gethitsajax(); }, getdownloadhits: function () { this.type = "getdownloadhits()"; this.callmethod = "getdownloadhits()"; this.gethitsajax(); }, gethitsajax: function () { $.ajax({ type: "post", url: "/ajaxfile/gethits.ashx", async: false, data: { type: this.type, callmethod: this.callmethod, id: this.id }, success: function (data) { html = data; } }); return document.write(html); } } //页面用法: