Object exist, object change value JS, JQuery
<p>When my application start this JSonResult doesn`t exist and when I would like to use this (I get error "TypeError")</p>

<pre><code>var newImg = $.parseJSON($("#UploadTarget").contents().find("#jsonResult")[0].innerHTML);
</code></pre>

<p>What I would like to do? I would like to have event which will tell me this object exist or this object change value.</p>

<pre><code> var newImg = $.parseJSON($("#UploadTarget").contents().find("#jsonResult")[0].innerHTML);
</code></pre>

<p>How should I write this?</p>

<pre><code>using System.Web.Mvc;

    namespace pol
    {
        public class WrappedJsonResult : JsonResult
        {
            public override void ExecuteResult(ControllerContext context)
            {
                context.HttpContext.Response.Write("&lt;html&gt;&lt;body&gt;&lt;textarea id=\"jsonResult\" name=\"jsonResult\"&gt;");
                base.ExecuteResult(context);
                context.HttpContext.Response.Write("&lt;/textarea&gt;&lt;/body&gt;&lt;/html&gt;");
                context.HttpContext.Response.ContentType = "text/html";
            }
        }
    }
</code></pre>

<p>When I click button Image is upload to server but Result never opent important method UploadImage_Complete(); </p>

<pre><code>@model po.Models.Stwna
@using (Html.BeginForm("UploadImage", "StronaGlowna", FormMethod.Post,
                                         new
                                             {
                                                 enctype = "multipart/form-data",
                                                 id = "ImgForm",
                                                 name = "ImgForm",
                                                 target = "UploadTarget"
                                             }))
{
    &lt;input type="file" name="imageFile" /&gt;

    &lt;input type="button" class="button" value="@Model.ZO" onclick="UploadImage()" /&gt;
}
&lt;iframe id="UploadTarget" name="UploadTarget" onload="UploadImage_Complete();" style="position: absolute;
    left: -999em; top: -999em;"&gt;&lt;/iframe&gt;
&lt;div id="Images"&gt;
&lt;/div&gt;
&lt;script type="text/javascript"&gt;
    var isFirstLoad = true;

    function UploadImage() {
        $("#ImgForm").submit();
    }
    function UploadImage_Complete() {
        //Check to see if this is the first load of the iFrame
        if (isFirstLoad == true) {
            isFirstLoad = false;
            return;
        }

        //Reset the image form so the file won't get uploaded again
        document.getElementById("ImgForm").reset();

        //Grab the content of the textarea we named jsonResult .  This shold be loaded into
        //the hidden iFrame.
        var newImg = $.parseJSON($("#UploadTarget").contents().find("#jsonResult")[0].innerHTML);

        //If there was an error, display it to the user
        if (newImg.IsValid == false) {
            alert(newImg.Message);
            return;
        }



        //Create a new image and insert it into the Images div.  Just to be fancy,
        //we're going to use a "FadeIn" effect from jQuery
        var imgDiv = document.getElementById("Images");
        var img = new Image();
        img.src = newImg.ImagePath;

        //Hide the image before adding to the DOM
        $(img).hide();
        imgDiv.appendChild(img);
        //Now fade the image in
        $(img).fadeIn(500, null);


       // $('#Images').text(newImg.ImagePath);
    }
&lt;/script&gt;
</code></pre>

<p>MVC</p>

<pre><code>[HttpPost]
        public WrappedJsonResult UploadImage(HttpPostedFileWrapper imageFile)
        {

            return new WrappedJsonResult
            {
                Data = new
                {
                    IsValid = true,
                    Message = string.Empty,
                    ImagePath = Url.Content(String.Format("http://a1.ec-images.myspacecdn.com/images01/29/4982945eb42646efafe2f94855ac3d21/l.jpg"))

                }
            };
        }
</code></pre>

<p>I get this image when I click button twice but when I click once I don`t get any result.</p>
