Lungo.Service.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * External Data & Services Manager
  3. *
  4. * @namespace LUNGO
  5. * @class Service
  6. * @requires QuoJS
  7. *
  8. * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
  9. * @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
  10. */
  11. LUNGO.Service = (function(lng, $$, undefined) {
  12. /**
  13. * Load data from the server using a HTTP GET request.
  14. *
  15. * @method get
  16. *
  17. * @param {string} Containing the URL to which the request is sent
  18. * @param {object} A map or string that is sent to the server with the request
  19. * @param {Function} Callback function after the request [OPTIONAL]
  20. * @param {string} Mime-Type: json, xml, html, or text [OPTIONAL]
  21. */
  22. var get = function(url, data, success, dataType) {
  23. return $$.get(url, data, success, dataType);
  24. };
  25. /**
  26. * Load data from the server using a HTTP POST request.
  27. *
  28. * @method post
  29. *
  30. * @param {string} Containing the URL to which the request is sent
  31. * @param {object} A map or string that is sent to the server with the request
  32. * @param {Function} Callback function after the request [OPTIONAL]
  33. * @param {string} Mime-Type: json, xml, html, or text [OPTIONAL]
  34. */
  35. var post = function(url, data, success, dataType) {
  36. return $$.post(url, data, success, dataType);
  37. };
  38. /**
  39. * Load data from the server using a HTTP GET request.
  40. *
  41. * @method json
  42. *
  43. * @param {string} Containing the URL to which the request is sent
  44. * @param {object} A map or string that is sent to the server with the request
  45. * @param {Function} [OPTIONAL] Callback function after the request
  46. */
  47. var json = function(url, data, success) {
  48. return $$.json(url, data, success);
  49. };
  50. return {
  51. get: get,
  52. post: post,
  53. json: json,
  54. Settings: $$.ajaxSettings
  55. };
  56. })(LUNGO, Quo);