1 include(bbq.ajax.AJAXRequest);
  2 
  3 bbq.ajax.ForwardingJSONRequest = Class.create(bbq.ajax.JSONRequest, /** @lends bbq.ajax.ForwardingJSONRequest.prototype */ {
  4 	/**
  5 	 * This class is designed to be used with the org.bbqjs.spring.ajax.RequestForwarder class
  6 	 * and attepts to work around the same origin policy of most browsers in terms of AJAX.
  7 	 *
  8 	 * The policy means that you can only dispatch an AJAX request to the server from which
  9 	 * the JavaScript dispatching the request was loaded.  So if you deliver your code from
 10 	 * http://www.example.org, you cannot make a request to http://api.google.com.
 11 	 *
 12 	 * The RequestForwarder class will forward on the request to the location specified in the
 13 	 * url property of the options argument, even if it's a different domain.
 14 	 *
 15 	 * Other than that it behaves in the same way as bbq.ajax.JSONRequest
 16 	 *
 17 	 * @example
 18 	 * <pre><code class="language-javascript">
 19 	 *
 20 	 * var request = new bbq.ajax.ForwardingJSONRequest({
 21 	 *     url: "http://api.google.com",
 22 	 *     onSuccess: function(serverRequest, json) {
 23 	 *
 24 	 *     }
 25 	 *     ... // more args similar to bbq.ajax.JSONRequest
 26 	 * });
 27 	 *
 28 	 * </code></pre>
 29 	 * @constructs
 30 	 * @param {Object} options
 31 	 * @extends bbq.ajax.JSONRequest
 32 	 */
 33 	initialize: function($super, options) {
 34 		options.forwardTo = options.url;
 35 		options.url = "/forward";
 36 		
 37 		$super(options);
 38 	},
 39 	
 40 	_createRequestHeaders: function() {
 41 		return {
 42 			"X-Content-Type": "application/json",
 43 			"X-BBQ-Forward-To": this.options.forwardTo
 44 		};
 45 	}
 46 });
 47