var gis = gis || {}; gis.server = function() { }; gis.server.jsonAjax= function(obj,successMethod,errorMethod){ var ajaxInfo={ type : 'post', dataType : 'json', //contentType : 'application/json;charset=utf-8', //timeout : 10000, //超时时间设置,单位毫秒 cache : false,// 不从缓存中去数据 async : true, //url : obj.url, //data : JSON.stringify(jsondate), //headers:headinfo, success : function(data) { if(successMethod){ successMethod(data); } }, error : function(jqXHR, textStatus, errorThrown) { //alert(jqXHR.responseText); if(errorMethod){ errorMethod(jqXHR, textStatus, errorThrown); } } }; ajaxInfo.url=obj.url; ajaxInfo.data=obj.data||{}; if(typeof(obj.dataType)!="undefined"){ ajaxInfo.dataType=obj.dataType } if(typeof(obj.async)!="undefined"){ ajaxInfo.async=obj.async } if(typeof(obj.contentType)!="undefined"){ //alert(obj.contentType); ajaxInfo.contentType=obj.contentType; } //alert(ajaxInfo); $.ajax(ajaxInfo); } gis.server.checking = function() { if(gis.script.isNotBlank(defdataUrl)){ //alert(defdataUrl); gis.server.jsonAjax({url:defdataUrl+".jsonp",dataType:"jsonp",async:true,data:{}}, function(data){ alert(JSON.stringify(data)) }); /* $.getJSON(defdataUrl+".json",function(json){ alert(JSON.stringify(json)); }); */ } }; $(document).ready(function() { //gis.server.checking(); });