-3

I need to make an Ajax call to get the image source from the server side using ASP.NET C#.

I got below code example:

$('#popup-container').click(function() {
  $.ajax({
    type: "GET",
    url: "img/popup_calculating.gif",
    dataType: "image/gif",
    success: function(img) {
      i = new Image();
      i.src = img;
      $(this).append(i);
    },
    error: function(error, txtStatus) {
    }
  });
});

The above code want to implement using ASP.NET C# .aspx pages, but I do not able to understand for implementation, to call images from the server, My requirements are to develop like below.

http://epaper.deccanchronicle.com/epaper_main.aspx#page986808

Marc
  • 3,905
  • 4
  • 21
  • 37
Mr doubt
  • 51
  • 1
  • 10
  • 42

1 Answers1

1

Well for a start, $(this) is not what you think it is because it's contained within a different scope (the success callback of the $.ajax request).

$('#popup-container').click(function() {
var container = $(this);
$.ajax({
    type: "GET",
    url: "img/popup_calculating.gif",
    dataType: "image/gif",
    success: function(imgSrc) {
      $(container).append('<img src="' + imgSrc + '" />);
    },
    error: function(error, txtStatus) {

    }
});

});

John Mc
  • 2,862
  • 1
  • 22
  • 37
  • I have to call from my image folder or what?. Please can you update your full code according to my requirement. @John Mc – Mr doubt Feb 29 '16 at 12:22