The requests attribute contains named HTTP requests.
Each definition can be any of
String, which will be interpreted as a URL for a GET requestObject that is compatible with
jQuery.ajax.Function that returns either of the aboveIf the URL is relative to the current help desk (e.g. /api/v2/tickets),
the request definition will passed directly to jQuery.ajax. If it is a
fully-qualified URL (e.g. http://example.com/widget), the request will
be proxied through Zendesk's servers.
Performs a named HTTP request.
name the name of a defined HTTP request*args any additional arguments, which will be passed to
the named request if it is a Function.A jQuery Promise that will
be resolved when the request does. Any done, fail, or always
callbacks will be passed the same arguments that the corresponding
callbacks for calls to jQuery.ajax. For successful requests, this
means they will receive the response body after it has been modified by
any jQuery dataFilters.
When the request returns, the [request name].always and either
the [request name].done or [request name].fail events will be
triggered. Any event handlers will also be passed the same arguments
as the promise callbacks.
{
requests: {
getWidget: function(name) {
return {
url: 'http://example.com/widgets/' + name,
dataType: 'json'
};
}
},
showWidget(name) {
this.ajax('getWidget', name)
.done(function(data) {
/// render the JSON data
});
}
}