I'm looking at the documentation for the watson API ( http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/qaapi/#apiRef ) but there isn't a clear way regarding how to use the API with client-side js. I'd like to use jquery's $.AJAX function.
How do I authenticate my account with the API using jquery and the send it a question? Once I get the json form the API, I can parse that, but how do I send it?
Here is how I'd think about doing this, but I don't know where I get the authentication information from BlueMix and then to where I send the request to get the JSON.
var questionJSON = {
'question': {
'evidenceRequest': {
'items' : 1
},
'questionText': question
}
};
$.ajax({
url: '' // url,
dataType: 'json',
method: 'PUT',
beforeSend: function(xhr){
//xhr.setRequestHeader('Authorization', 'Basic '+btoa(accessToken+':'));
},
success: function(answerJSON){
// parse answerJSON
}
});