Problem with images, binding load events and http codes

Problem with images, binding load events and http codes

Hello all.

I have some problems with an ajax call that should be quite simple and now I'm completely lost, so any help would be great.

Ok, let's go:

I have a web page working at this moment, ok, and I use $.get() to load a table into it (html format), this is working ok too. When user clicks in <tr> tags, I use $.get() another time to get some more html data, including an image as an <img src=". . .">.

the server send me the image only if a user loaded it previously from an external 'admin site', or HTTP 204 code if requested image doesn't exist.

I have two problems: First all, I'm unable to bind a load event to my image, no matter how I do it.
I tried $("img").on(), $("img").live() and both with $("img", data). I tried also with an Image object. All this code is in $(function(){ . . . }).

And the second one, How can I take the return code for an image from the load event? HTTP 204 will fire a load success event, as far as I read.

Does exist another way to proceed? If does, please, put me on the way.

My code:
 
  1. $(function(){
  2.  . . .
  3.  /*Works-result is my table, when I click in a tr.header, a tr.tab-content expands with new data*/
     $("#works-result").on("click", "#table-works tr.tab-header", function (event) {
         var $content = $(this).next("tr.tab-content");

  4.      /*If clicked tr has not loaded yet, load data into it.*/
         if ($content.find("td div.detail").length == 0) {
  5.   /*Calling my server to get html data for this tr*/
      $.when($.get($content.attr("codwork"))).then(function (data) {
  6.       /*I'm unable to make it work in any way!*/
          $("img", data).live("load", function () { . . . });
          //$("img", data).on("load", function () { . . . });
          //$("img").live("load", function () { . . . });
          //$("img").on("load", function () { . . . });



  7.       //I tried it binding events out here, directly under $(function(){});
  8.       $content.find("td").append(data);
  9.   }, function () { alert("error") });
  10.      }
        
     });
     
     . . .



  11. });
Thanks a lot in advance.
Regards.