Get input value from a loaded page

Get input value from a loaded page

Hi all,
I have index.html, where jquery is loaded.
In this main page i need to load an external .php page:

$("#top").load("top.php");

and all work well.
In top.php page, there's a input hidden like this:

<input type="hidden" id="counter" value="<?=$Count;?>">

Now The question: how can i do for retrieve the input value and use it in index.html page?
I have try this but not work:

var numsg = $("#counter").val();

Thanks