e5bf7756b909afb66b5bb1219a3267f5e0ce5551.svn-base 742 B

1234567891011121314151617181920212223242526272829303132333435
  1. var util = {
  2. g_url:"http://127.0.0.1:8081/",
  3. ajax_arr: function(url, data, method, success_fn, error_fn) {
  4. $.ajax({
  5. url: url,
  6. data: JSON.stringify(data),
  7. type: method,
  8. headers: {'Content-Type': 'application/json;charset=utf-8'},
  9. dataType: 'json',
  10. success: function(res){
  11. //res = JSON.parse(res)
  12. console.log(res)
  13. if (res.code == 1 || res.code == 200) {
  14. success_fn(res)
  15. } else {
  16. if (error_fn) {
  17. error_fn(res)
  18. }
  19. }
  20. },
  21. error: function (error) {
  22. console.log("请求出错原因:",error);
  23. }
  24. });
  25. },
  26. }