Class bbq.ajax.JSONRequest

Extends bbq.ajax.AJAXRequest.
Defined in: JSONRequest.js.

Sends an asynchronous HTTP request to a server. The passed arguments are serialized to a JSON string and the response is also expected to be a JSON string. The request goes out as a POST request and the JSON string is sent as the request body.

new bbq.ajax.JSONRequest({
    // The URL to send the request to - can be relative
    url: "/some/path",

    // The arguments to send - N.B. will be JSON serialized
    args: {
         foo: "bar"
    }

    // Invoked on success.
     // The first argument is the XMLHTTPRequest object,
     // the second is the deserialized server response
    onSuccess: function(serverResponse, json) {

    },

    // Invoked when the request fails - eg. a X-BBQ-ResponseCode
    // header is sent with a negative value
    onFailure: function() {

    }
});

Class Summary
Constructor Attributes Constructor Name and Description
 
bbq.ajax.JSONRequest(options, options)
Sends an asynchronous HTTP request to a server.
Fields borrowed from class bbq.ajax.AJAXRequest:
options

Constructor Detail

bbq.ajax.JSONRequest(options, options)

Parameters:
Name Type Comment
options {Object}
options