如何使用Javascript

时间:2015-12-09 09:41:50

标签: javascript



$(document).ready(function() {
  var request = $.ajax({
    url: "./lib/endpoint_v3.php",
    type: "GET",
    data: {
      method: "resource/get",
      search: "",
      type: "personal"
    },
    dataType: "json"
  }).done(function(response) {
    $('.progress-measure').hide();
    var external_url;

    console.log(response);

    // $('.progress-measure').hide();
    for (var uuid in response.response) {
      external_url = response.response[uuid].external_url;
      extension = (response.response[uuid])
      console.log(extension);
      if (extension == "jpg" || extension == "png") {
        show_image(external_url, 200, 200, response.response[uuid].attachment.name, "image");
      }
    };
    console.log(response);

    function show_image(src, width, height, alt, tag) {
      var img = document.createElement("img");
      img.src = src;
      img.width = width;
      img.height = height; // you can delete the height if you do not want the imaged stretched
      img.alt = alt;


      // This next line will just add it to the <body> tag
      document.body.appendChild(img);
    }
  });
});
&#13;
&#13;
&#13;

0 个答案:

没有答案