框架中的Ajax加载div

I have a php page that I designed a div to be populated by an Ajax call.

function showcopay()
 {

var apa = document.getElementById("alert_id").value;

 $("#copay").load('show_copay.php?pid='+apa);


 }

The parent page of the div used to be a popup page. I have moved the page to an iframe. Ajax does not work any more. When I click the link to load the div. Nothing happens.

The content file (show_copay.php) that is being called is in same folder as the parent file as before. Nothing moved as I stated before. I moved the parent page to the iframe and everything stopped working.

Do I need to include a path to the file?

The ajax was being more precise than imagined in the first place. Because the

 doucment.getElementById("alert_id").value 

was returning a null value (which was shown in the console but I was ignoring it). The console was showing an uncaught exception. So adding the try block around it solved the problem. Now the page works like it use to work.

      function showcopay()
       {
        try{
              var apa = document.getElementById("alert_id").value;
           }catch(err){

        }
           $("#copay").load('show_copay.php?pid='+apa);

        }