(function(){ fangjia = new Object; fangjia.districtTool = { elId:'', cityName : '', regionName : '', districtName : '' } fangjia.districtTool.init = function(){ var _this = fangjia.districtTool; var e=_this.elId; _this.cityName=encodeURI(_this.cityName==''?'上海':_this.cityName); _this.regionName=encodeURI(_this.regionName); _this.districtName=encodeURI(_this.districtName); var _param = serializeJson(_this); var _url = 'http://open.fangjia.com'; var _html = []; _html.push('') _html.push(''); _html.push(''); if(e!=null && typeof e == 'string' && document.getElementById(e)){ document.getElementById(e).innerHTML = _html.join(''); }else{ document.write(_html.join('')); } } /** * json序列化 */ /** * json序列化 */ var serializeJson = function(o){ if(typeof o != 'object'){ return o; } var ret = []; for (var key in o) { if(typeof o[key] == 'function'){ continue; } if(o[key] != null && typeof o[key] == 'object' && o[key].length>0){ for ( var i = 0; i < o[key].length; i++) { if(typeof o[key][i] == 'string' || typeof o[key][i] == 'number'){ ret.push(key); ret.push('='); ret.push(o[key][i]); ret.push('&'); } } }else if(o[key] != null){ ret.push(key); ret.push('='); ret.push(o[key]); ret.push('&'); } } if(ret.length>0){ ret[ret.length-1] = ''; } return ret.join(''); };})()