Hi All,
I have been trying to get the widget to visualize the data from the server by calling the .show() method outlined in the documentation, however, it seems that the call to the API from the client is returning a 503 service not available status code. I am not really sure why or what else to go on, as the documentation really does not offer much information about the TA widget. Here is a snippet of my AJAX call on the client side:
$(document).ready(function(){
var button = $('.button');
var opts = {
dilemmaServiceUrl : 'http://gateway.watsonplatform.net/v1/tradeoff-analytics/api'
};
var TA = new TradeoffAnalytics(opts, 'widget');
button.click(function(){
$.ajax({
url: '/tradeoff_analytics',
type: 'POST',
success: function(res){
$('#widget').show();
TA.start(function(){
console.log('TA service started');
});
TA.show(res);
},
error: function(status){
console.log('There was an error: ' + status);
}
});
});
});
Any help would be greatly appreciated, thanks.
Answer by 6HV0_David_Boaz (561) | Jun 07, 2015 at 12:22 AM
enter code here
I have few items to add to David Amid's comment. There are 2 ways to use the TA service: Calling the service directly, or using the widget. In the second option, the widget calls the service by it self. You (the consuming application) just need to create the widget with the correct options call start() and then show(data).
In your example, it seems that you mixed the two approaches.
If you want to use the ui widget: I assume that url: '/tradeoff_analytics', refers to a local service you use to proxy the TA service. Instead, you should pass this proxy service url to the dilemmaServiceUrl option.
If you call the service directly: a) You are not passing any data (payload) to the service b) The request should contain this header: Content-Type:application/json
One more comment: start() takes time. the callback function notifies you when the TA instance was started. Only then you can call show(). Hence, I recommend to put the call to show() in the staret callback.
Would it be possible to include options that are incomplete in Tradeoff Analytics visualization? 2 Answers
Tradeoff Analytics: Why are two options combined under a parent? 1 Answer
Obtain rank values with Tradeoff Analytics 1 Answer
Customization of Tradeoff Analytics Widget version 2 2 Answers
Deploying modified Tradeoff Analytics Node application 1 Answer