Not "java", "JavaScript"
What semodders' referring to is usually known as the hidden (i)frame method. It's an old way of simulating asynchronous requests by requesting a page from the server into the hidden frame and then read that data from the main frame when it's done loadig. Sometimes, a small script is included in every requested page which simply calls a function on the main page to notify it that loading is complete.
This approach is usually used as a fallback if the xmlHttpRequest object (used by modern AJAX implementations) isn't available.
Allthough I doubt you need AJAX at all if you only want to change an image (and update cookies) since you only need to change the src property of the image to trigger a new request.