关于jquery中.getScript()的问题
function ntes_marketrank(options){
var options = options || {};
this.page = options["page"] || 0;
this.count = options["count"] || 40;
this.sort = options["sort"] || "SYMBOL";
this.order = options["order"] || "asc";
this.query = options["query"] || "STYPE:EQA";
this.host = options["host"] || "http://quotes.money.163.com/hs/service/marketrank.php";
//this.host = options["host"] || "/cache/marketrank.php";
var _self = this;
this.pagecount = 0;
this.total = 0;
this.list = [];
this.onload = function(sender){
// 回调函数
}
// 载入数据
this.load = function (options) {
var options = options || {};//
this.page = options["page"] || this.page;
this.count = options["count"] || this.count;
this.sort = options["sort"] || this.sort;
this.order = options["order"] || this.order;
this.query = options["query"] || this.query;
this.host = options["host"] || this.host;
var params = { "page": _self.page, "count": _self.count, "sort": _self.sort, "order": _self.order, "query": _self.query, "callback": "_market_rank_loaded" };
window._market_rank_loaded = function (json) {
// 更新信息
_self.page = json.page;
_self.total = json.total;
_self.count = json.count;
_self.pagecount = json.pagecount;
_self.order = json.order;
_self.list = json.list;
// 回调
_self.onload(_self);
}
// 插入JS
_$.getScript(this.host + "?" + _$.param(params));
}
// 翻页
this.gotopage = function(page){
if(page>=0 && page<=_self.pagecount-1){
_self.page = page;
this.load();
return true;
}else{
return false;
}
}
// 下一页
this.next = function(){
return _self.gotopage(_self.page + 1);
}
// 上一页
this.prev = function(){
return _self.gotopage(_self.page - 1);
}
// 首页
this.first = function(){
return _self.gotopage(0);
}
// 末页
this.last = function(){
return _self.gotopage(_self.pagecount-1);
}
}
我从教材上看关于.getScript()的详解中 .getScript()是通过 AJAX 请求来获得并运行一个 JavaScript 文件:
但上面的代码.getScript()中的参数url的值是marketrank.php页面后加参数,谁能详细解释一下,万分感谢
------解决方案--------------------
getScript 仅仅是发送个请求,
通过 HTTP GET 请求载入并执行一个 JavaScript 文件。
getJSON 可以返回一个 JSONP 的回调函数。
通过 HTTP GET 请求载入 JSON 数据。