anayrun.js 648 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * 异步通信处理
  3. */
  4. var anayrun = {
  5. init:function(){
  6. },
  7. send:function(url,cans){
  8. var lx = (url.indexOf('?')<0) ? '?' : '&';
  9. url+=''+lx+'rnd='+js.getrand()+'';
  10. if(!cans)cans={};
  11. for(var i in cans)url+='&'+i+'='+cans[i]+'';
  12. $.ajax({
  13. url:url,
  14. type:'get',
  15. success:function(str){
  16. if(str!='success'){
  17. anayrun.senderror(str, url);
  18. }
  19. },
  20. error:function(e){
  21. anayrun.senderror(e.responseText, url);
  22. }
  23. });
  24. },
  25. senderror:function(str, url){
  26. notifyobj.show({
  27. title:'JS异步处理',
  28. type:'error',
  29. body:'地址:'+url+',处理出错:'+str+''
  30. });
  31. }
  32. };