gis.superMap.iServer.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. var gis = gis || {};
  2. gis.server = function() {
  3. };
  4. gis.server.jsonAjax= function(obj,successMethod,errorMethod){
  5. var ajaxInfo={
  6. type : 'post',
  7. dataType : 'json',
  8. //contentType : 'application/json;charset=utf-8',
  9. //timeout : 10000, //超时时间设置,单位毫秒
  10. cache : false,// 不从缓存中去数据
  11. async : true,
  12. //url : obj.url,
  13. //data : JSON.stringify(jsondate),
  14. //headers:headinfo,
  15. success : function(data) {
  16. if(successMethod){
  17. successMethod(data);
  18. }
  19. },
  20. error : function(jqXHR, textStatus, errorThrown) {
  21. //alert(jqXHR.responseText);
  22. if(errorMethod){
  23. errorMethod(jqXHR, textStatus, errorThrown);
  24. }
  25. }
  26. };
  27. ajaxInfo.url=obj.url;
  28. ajaxInfo.data=obj.data||{};
  29. if(typeof(obj.dataType)!="undefined"){
  30. ajaxInfo.dataType=obj.dataType
  31. }
  32. if(typeof(obj.async)!="undefined"){
  33. ajaxInfo.async=obj.async
  34. }
  35. if(typeof(obj.contentType)!="undefined"){
  36. //alert(obj.contentType);
  37. ajaxInfo.contentType=obj.contentType;
  38. }
  39. //alert(ajaxInfo);
  40. $.ajax(ajaxInfo);
  41. }
  42. gis.server.checking = function() {
  43. if(gis.script.isNotBlank(defdataUrl)){
  44. //alert(defdataUrl);
  45. gis.server.jsonAjax({url:defdataUrl+".jsonp",dataType:"jsonp",async:true,data:{}},
  46. function(data){
  47. alert(JSON.stringify(data))
  48. });
  49. /*
  50. $.getJSON(defdataUrl+".json",function(json){
  51. alert(JSON.stringify(json));
  52. });
  53. */
  54. }
  55. };
  56. $(document).ready(function() {
  57. //gis.server.checking();
  58. });