Javascript 闭包访问问题?

时间:2024-10-18 20:03:56
function pfajax(paradata){
$.ajax({
data : paradata.dat,
type : paradata.method,
async: false,
url : "http://222.192.41.119:8080/info/android/"+paradata.url,
dataType : "jsonp",//数据类型为jsonp
jsonp: "jsonpCallback",//服务端用于接收callback调用的function名的参数
contentType : "application/json; charset=utf-8",
success : function(ret){
var object = JSON.parse(decodeURIComponent(ret));
paradata.sucfunction(object);
//console.log(object.adminname);
//alert(object);
},
error:function(){
alert('fail');
}
});
} function mainupdte() {
var jfid = 1;
var senddat = {};
senddat.url = "area";
senddat.dat = {};
senddat.method = 'get';
senddat.sucfunction = function(ret){
jfid = ret[0].jfid; //★★我想获取这里的jfid怎么破???
for(var i = 0;i<ret.length;i++){
var option = $("<option jfid='"+ret[i].jfid+"'>"+ret[i].address+"</option>");
$("#frame0 select").append(option);
}
return jfid;
}
pfajax(senddat);
} //jquery ready function
$(function(){
var getjfidfun = mainupdte();
selectchange(jfid);
});