common.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. var baseUrl = 'http://pay-test.278740.cn'
  2. /**
  3. * 获取请求ajax数据
  4. * @param url 请求地址
  5. * @param type 请求类型
  6. * @param data 需要发送的数据
  7. * @param callback 成功回调方法
  8. * @param alert 成功后是否提示成功信息
  9. */
  10. var getAjax = function (url, type, data, callback, alert, noneShow,errorF) {
  11. // !noneShow ? showLoading() : null;
  12. $.ajax({
  13. url: url,
  14. type: type,
  15. dataType: 'JSON',
  16. data: data,
  17. success: function (result) {
  18. if (result.state == 0) {
  19. typeof callback == 'function' ? callback(result) : null;
  20. if (alert) Popup.toast(result.msg || " ");
  21. // !noneShow ? hideLoading() : null;
  22. } else {
  23. Popup.toast(result.msg || " ");
  24. // !noneShow ? hideLoading() : null;
  25. typeof errorF == 'function'?errorF():null;
  26. }
  27. },
  28. error: function (err) {
  29. Popup.toast(err || " ");
  30. // !noneShow ? hideLoading() : null;
  31. typeof errorF == 'function'?errorF():null;
  32. }
  33. })
  34. };