function submitInfoRequest()
{
$('#info').html("Please wait...");
$('#fullRes').val("");
$('#fullRes').attr("rows", 8);
$.support.cors = true;
var inputData = $('#inputText').val();
var token = $('#token').val();
var ajaxOpts = {
type: 'POST',
dataType: "text",
data: inputData,//"IBM is a company in the USA",
url: "https://api.thomsonreuters.com/permid/calais?access-token=" + token,
beforeSend: function ( jqXHR, settings )
{
jqXHR.setRequestHeader('Content-Type', 'text/raw');
jqXHR.setRequestHeader('OutputFormat', 'application/json');
jqXHR.setRequestHeader('X-AG-Access-Token', 'SAksBfBgxUmQyQQ9WA2MGig5dHuesPnu');
},
success: function ( data, textStatus, jqXHR )
{
var json = jQuery.parseJSON( jqXHR.responseText );
var map = new Object();
for(var i in json) {
var p = json[i];
for (var key in p) {
if (p.hasOwnProperty(key) && (key == "name")) {
if(p.hasOwnProperty('_type'))
{
if(!map.hasOwnProperty(p._type)) {map[p._type] = "";}
if(p.hasOwnProperty('resolutions'))
{
map[p._type] = map[p._type] + "\n
" + p[key] + " \n
Full Name: "
+ p.resolutions[0].name + "
";
if(p.resolutions[0].hasOwnProperty('openpermid'))
{
map[p._type] = map[p._type] + "
OpenPermid: " + p.resolutions[0].openpermid;
}
map[p._type] = map[p._type] + "";
}
else
{
map[p._type] = map[p._type] + "";
map[p._type] = map[p._type] + p[key];
map[p._type] = map[p._type] + "";
}
}
}
}
}
var strTable = "";
for (var mapKey in map) {
strTable += "";
}
strTable += "
"+mapKey+" | "
strTable += map[mapKey]+" |
---|
|
";
if(strTable == "
")
{
strTable = "Sorry, no match found.";
}
else
{
strTable = "For full data try hovering over the results...
" + strTable;
}
$('#info').html(strTable);
$('#fullRes').attr("rows", 60);
$('#fullRes').val(JSON.stringify(json, undefined, 2));
},
error: function ( jqXHR, textStatus, errorThrown )
{
$('#info').html("
" + textStatus + "
" + jqXHR.state() + "
" + errorThrown);
}
};
$.ajax( ajaxOpts );
}
function submitInfoRequest()
{
$('#info').html("Please wait...");
$('#fullRes').val("");
$('#fullRes').attr("rows", 8);
$.support.cors = true;
var inputData = $('#inputText').val();
var token = $('#token').val();
var ajaxOpts = {
type: 'POST',
dataType: "text",
data: inputData,//"IBM is a company in the USA",
url: "https://api.thomsonreuters.com/permid/calais?access-token=" + token,
beforeSend: function ( jqXHR, settings )
{
jqXHR.setRequestHeader('Content-Type', 'text/raw');
jqXHR.setRequestHeader('OutputFormat', 'application/json');
jqXHR.setRequestHeader('X-AG-Access-Token', 'SAksBfBgxUmQyQQ9WA2MGig5dHuesPnu');
},
success: function ( data, textStatus, jqXHR )
{
var json = jQuery.parseJSON( jqXHR.responseText );
var map = new Object();
for(var i in json) {
var p = json[i];
for (var key in p) {
if (p.hasOwnProperty(key) && (key == "name")) {
if(p.hasOwnProperty('_type'))
{
if(!map.hasOwnProperty(p._type)) {map[p._type] = "";}
if(p.hasOwnProperty('resolutions'))
{
map[p._type] = map[p._type] + "\n
" + p[key] + " \n
Full Name: "
+ p.resolutions[0].name + "
";
if(p.resolutions[0].hasOwnProperty('openpermid'))
{
map[p._type] = map[p._type] + "
OpenPermid: " + p.resolutions[0].openpermid;
}
map[p._type] = map[p._type] + "";
}
else
{
map[p._type] = map[p._type] + "";
map[p._type] = map[p._type] + p[key];
map[p._type] = map[p._type] + "";
}
}
}
}
}
var strTable = "";
for (var mapKey in map) {
strTable += "";
}
strTable += "
"+mapKey+" | "
strTable += map[mapKey]+" |
---|
|
";
if(strTable == "
")
{
strTable = "Sorry, no match found.";
}
else
{
strTable = "For full data try hovering over the results...
" + strTable;
}
$('#info').html(strTable);
$('#fullRes').attr("rows", 60);
$('#fullRes').val(JSON.stringify(json, undefined, 2));
},
error: function ( jqXHR, textStatus, errorThrown )
{
$('#info').html("
" + textStatus + "
" + jqXHR.state() + "
" + errorThrown);
}
};
$.ajax( ajaxOpts );
}