javascript - How to get textOperations and Get Result? -


i need "post" textoperations , use received value "get" , return results.

i'm doing "post" not in console.log (), how "id" received , use in "get" return results?

the api name is:

microsoft face api

my code:

function handwriteentextapi(){    // chave de inscriÇÃo da api.   var api_key = "";    // deve-se utilizar mesma região em que chave de escrição da api está   // nota: chaves de inscrições de testes são geradas na região "westcentralus".   var uribase = "https://westcentralus.api.cognitive.microsoft.com/vision/v1.0/recognizetext?";    // solicitar parâmetros de retorno json.   var params = {     "handwriting": "true"   };    // mostra imagem recebida da url   var sourceimageurl = document.getelementbyid("inputurlimage").value;   document.queryselector("#imagereceived").src = sourceimageurl;    // executa chamada da api restfull via ajax.   $.ajax({      // utiliza uribase para retornar os valores dos parâmetros     url: uribase + $.param(params),      // solicita os headers     beforesend: function(xhrobj){       xhrobj.setrequestheader("content-type","application/json");       xhrobj.setrequestheader("ocp-apim-subscription-key", api_key);     },      // tipo ajax     type: "post",      // solicita o body     data: '{"url": ' + '"' + sourceimageurl + '"}',   })    .done(function(data) {     // recebe o json e transforma em um objeto     var objjson = json.parse(json.stringify(data, null, 2));     console.log(objjson);      })   .fail(function(jqxhr, textstatus, errorthrown) {     // mostra mensagens de erro.     var errorstring = (errorthrown === "") ? "error. " : errorthrown + " (" + jqxhr.status + "): ";     errorstring += (jqxhr.responsetext === "") ? "" : jquery.parsejson(jqxhr.responsetext).message;     alert(errorstring);   });  }; 

when successful, post request responds http 202, typically contains no response body. url contained instead in operation-location http header. here's how might extract it:

  .done(function(data, textstatus, jqxhr) {     // recebe o json e transforma em um objeto     if (jqxhr.status == 202) {       console.log(jqxhr.getresponseheader('operation-location'))     }   }) 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -