In my first Cordova Application, I am eager to implement Face API by Microsoft Cognitive Services. Although I have successfully utilized MS Cognitive Services in C# & XAML code, I now aim to integrate it with JavaScript for my Cordova application. Code:
var app = {
initialize: function () {
this.bindEvents();
},
onDeviceReady: function () {
document.getElementById("take-picture-button").addEventListener("click", function () {
appState.takingPicture = true;
navigator.camera.getPicture(cameraSuccessCallback, cameraFailureCallback,
{
sourceType: Camera.PictureSourceType.CAMERA,
destinationType: Camera.DestinationType.FILE_URI,
//destinationType: Camera.DestinationType.DATA_URL,
targetWidth: 500,
targetHeight: 500
}
);
}); } function cameraSuccessCallback(imageUri) {
appState.takingPicture = false;
appState.imageUri = imageUri;
document.getElementById("get-picture-result").src = imageUri;
// Code for Face Detection
var params = {
"returnFaceId": "true",
"returnFaceLandmarks": "true",
"returnFaceAttributes": "{string}",
};
var body = { "url" : ""+imageUri };
$.ajax({
url: "CorrectURL/detect?" + $.param(params),
beforeSend: function (xhrObj) {
xhrObj.setRequestHeader("Content-Type", "application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key", "KEY-Value");
},
type: "POST",
data: JSON.stringify(body),
})
.done(function (data) {
alert("success");
})
.fail(function () {
alert("error");
});
// End of Face Detection Code }
I am facing an issue where the Ajax call is not being executed as expected. Upon checking on Azure Portal, I noticed that there are no calls registered. Seeking assistance from anyone who can provide guidance on resolving this problem.
Thank You