Search code examples
javascriptajaxazureazure-machine-learning-service

Azure Machine Learning using Javascript Ajax call


I wanted to know if there is a way to call the Azure Machine Learning webservice using JavaScript Ajax.

The Azure ML gives sample code for C#, Python and R.

I did try out to call the webservice using JQuery Ajax but it returns a failure.

I am able to call the same service using a python script.

Here is my Ajax code :

  $.ajax({
        url: webserviceurl,
        type: "POST",           
        data: sampleData,            
        dataType:'jsonp',                        
        headers: {
        "Content-Type":"application/json",            
        "Authorization":"Bearer " + apiKey                       
        },
        success: function (data) {
          console.log('Success');
        },
        error: function (data) {
           console.log('Failure ' +  data.statusText + " " + data.status);
        },
  });

Solution

  • Well after a lot of RnD, I was able to finally call Azure ML using some workarounds.

    Wrapping Azure ML webservice on Azure API is one option.

    But, what I did was that I created a python webservice which calls the Azure webservice.

    So now my HTML App calls the python webservice which calls Azure ML and returns data to the HTML App.