function parse() {
  var elements = document.getElementsByTagName("img")

  for (var i = 0; i < elements.length; i++) {
    processImage(elements[i].src, elements[i]);
  }
}

function processImage(source, element) {
    var subscriptionKey = "20613855066847539021532e06e9ce11";
    var uriBase = "https://westcentralus.api.cognitive.microsoft.com/vision/v1.0/analyze";

    var params = {
        "visualFeatures": "Categories,Description,Color",
        "details": "",
        "language": "en",
    };

    var sourceImageUrl = source;

    $.ajax({
        url: uriBase + "?" + $.param(params),
            beforeSend: function(xhrObj){
            xhrObj.setRequestHeader("Content-Type","application/json");
            xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
        },
        type: "POST",
        data: '{"url": ' + '"' + sourceImageUrl + '"}',
    })

    .done(function(data) {
        var ret= data.description.captions[0].text;
        if (element.alt != "") {
          element.alt ="Original caption: " + element.alt + " Generated caption: " + ret;
        } else {
          element.alt = "Generated caption: " + ret;
        }
    })

    .fail(function(jqXHR, textStatus, errorThrown) {
        // Display error message.
        var errorString = (errorThrown === "") ? "Error. " : errorThrown + " (" + jqXHR.status + "): ";
        errorString += (jqXHR.responseText === "") ? "" : jQuery.parseJSON(jqXHR.responseText).message;
        alert(errorString);
    });
};

@@ -1,25 +1,4 @@
-function parse() %7B%0A  
 var 
@@ -46,18 +46,16 @@
 %22img%22)%0A%0A
-  
 for (var
@@ -90,18 +90,16 @@
  i++) %7B%0A
-  
   proces
@@ -140,13 +140,10 @@
 %5D);%0A
-  
 %7D%0A
-%7D
 %0A%0Afu
@@ -895,19 +895,24 @@
     var 
-ret
+caption 
 = data.d
@@ -1034,16 +1034,17 @@
 .alt + %22
+;
  Generat
@@ -1051,35 +1051,39 @@
 ed caption: %22 + 
-ret
+caption
 ;%0A        %7D else
@@ -1137,11 +1137,15 @@
 %22 + 
-ret
+caption
 ;%0A  

adding semicolon to caption