Q:

If statement(text exist in iframe) in Javascript for Iframe not working

Hi I am new to this site and trying to get some help on this small problem. 
I am trying to see if a set of text (Listing Added) Exists in the iframe then do something with it, if it exists etc. 
I have read that there are 2 ways of doing it 
1st $('#my_iframe:contains("I am a simple string")')
2nd $('#my_iframe').contents().find().text('my text').length>0
I tried both and the problem that i have is my if statement does not work. If the text exists or not, it is going to the first condition. 
Thanks for your time!
Here is my code 

<script>        
    $(function(){
        $('#myiframe').load(function(){
        if ($('#myiframe:contains("Listing Added")')){
            document.getElementById('result').innerHTML = "Listing Added!"
        }
        else{
            document.getElementById('result').innerHTML= "Listing not Added"}
        });
    });       
</script>

A:

If page in iFrame is not from the same origin (protocol, port and url) as the script then forget it 
you may be too late with the .load since you do not assign the event handler until after 
the page loaded 

Assuming the text is in a span
$(function() {
  var $container = $("#myiframe").contents().find("span:contains('Listing Added')"),
      added = $container.length>0?" ":" not ";
  $("#result").html("Listing"+added+"Added!");
});

But why not
 $(function() {
   $.get("mylist.ext",function(data) { // or $.post if needed
     var added = data.indexOf("Listing Added") !=-1;
     $("#result").html("Listing"+(added?" ":" not ")+"Added");
     $("#someContainer").html(data); // instead of iframe
   });
 });

