Use IBM watson API with jquery's $.ajax Use IBM watson API with jquery's $.ajax json json

Use IBM watson API with jquery's $.ajax


Please take a look at my tutorial on IBM developerWorks on using Watson's Question and Answer service - http://www.ibm.com/developerworks/cloud/library/cl-watson-qaapi-app/index.html#N10229

RegardsGanesh


I believe you may need to use similar logic like below:

function addUser(event){.......................$.ajax({    url: '/users/adduser',,dataType: 'json',method: 'PUT',beforeSend: function(xhr){    //xhr.setRequestHeader('Authorization', 'Basic '+btoa(accessToken+':'));},success: function(answerJSON){    // parse answerJSON}}); };

/* * POST to adduser. */

router.post('/adduser', function(req, res) {var db = req.db; db.collection('userlist').insert(req.body, function(err, result){    res.send(        (err === null) ? { msg: '' } : { msg: err }    );    });});

you can follow below link for more info on client side js:

http://cwbuecheler.com/web/tutorials/2014/restful-web-app-node-express-mongodb/


You are trying to do a Cross-domain requests (http://en.wikipedia.org/wiki/Same-origin_policy). That is not possible.

The only way to call the qa service from the client side its by using jsonp (http://en.wikipedia.org/wiki/JSONP). but that is not supported now. I will suggest you to create an app in Bluemix and use it as proxy between your code and the service.