This document details the general attributes that can be set in the request. In the current version only response "resp" is valid for the scope of this document.
The following parameters can be sent in the querystring
Parameter | Attribute | Description | Default Value | Data Type | Mandatory |
resp | fallback | This object specifies the text to display if the action fails. For example if the action is a search and there is no result, the value of this parameter will be set. Use case:"fallback":"+44201200300" | STRING | YES | |
elementsBy | Object to determine which HTML elements to populate and how to populate them | OBJECT | NO | ||
"elementsBy":{"match":...} | The match property of elementsBy determines what type of HTML attribute to populate. Possible values are id, name and className. Example:"match":"className" | id | STRING | NO | |
"elementsBy":{"element":...} | The element property of elementsBy determines the name of the HTML attribute to populate:"element":"myHtmlElementClassname" | iovoxRes | STRING | NO |
Example 1 - Bare Minimum¶
- Uses no VoxReq.resp object so defaults from above table are used - Will not populate fallback data as it is not specified
<script type="text/javascript">
var VoxReq = {}; // Initialise object
VoxReq.auth = {"accK":"ge803fbc4629d15aae13ab9fe8c1e187d8c62de9","actK":"fe8c1e187d8c62de9ge803fbc4629d15aae13ab9"}; // Authentication
VoxReq.data = {"l":"Notting Hill Flat"}; // Data for request
// Notice, VoxReq.resp not set
(function() {
var vox = document.createElement('script'); vox.type = 'text/javascript';
vox.src = ('https:' == document.location.protocol ? 'https://www' : 'http://www') + '.voxanalytics.com/js/api/vox.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(vox, s);
})();
</script>
Success Result¶
document.getElementById('phonenumber').innerHTML = '+442071112222'; // VoxNumber for Link matching Link ID "Notting Hill Flat"
Failure Result - Empty as there is no "fallback" parameter set in the request¶
Example 1 - Specify HTML ID to populate and fallback to +442071002000¶
- The HTML element with ID "phonenumber" will be populated - If the search for "Link ID = Notting Hill Flat" does not work then the fallback value (+442071002000) will be displayed
<script type="text/javascript">
var VoxReq = {}; // Initialise object
VoxReq.auth = {"accK":"ge803fbc4629d15aae13ab9fe8c1e187d8c62de9","actK":"fe8c1e187d8c62de9ge803fbc4629d15aae13ab9"}; // Authentication
VoxReq.data = {"l":"Notting Hill Flat"}; // Data for request
VoxReq.resp = {"elementsBy":{"match":"id","element":"phonenumber"},"fallback":"+442071002000"}; // How to handle response
(function() {
var vox = document.createElement('script'); vox.type = 'text/javascript';
vox.src = ('https:' == document.location.protocol ? 'https://www' : 'http://www') + '.voxanalytics.com/js/api/vox.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(vox, s);
})();
</script>
Success Result¶
document.getElementById('phonenumber').innerHTML = '+442071112222'; // VoxNumber for Link with ID "Notting Hill Flat"