Requires

Provides

Extends the basic Request Class with additional methods for sending and receiving JSON data.

License:
MIT-style license.
  1. 18
  2. 19
  3. 20
  4. 21
  5. 22
  6. 23
  7. 24
  8. 25
  9. 26
  10. 27
  11. 28
  12. 29
  13. 30
  14. 31
  15. 32
  16. 33
  17. 34
  18. 35
  19. 36
  20. 37
  21. 38
  22. 39
  23. 40
  24. 41
  25. 42
  26. 43
  27. 44
Request.JSON = new Class({ Extends: Request, options: { secure: true }, initialize: function(options){ this.parent(options); Object.append(this.headers, { 'Accept': 'application/json', 'X-Request': 'JSON' }); }, success: function(text){ var secure = this.options.secure; var json = this.response.json = Function.attempt(function(){ return JSON.decode(text, secure); }); if (json == null) this.onFailure(); else this.onSuccess(json, text); } });