7 Replies Latest reply on May 8, 2017 3:31 AM by natalie-james

    jQuery .load() a .cfm page - displays blank (FireBug shows blank result from GET)

    WolfShade Level 4

      Hello, all,

       

      I've got a page where I'm using CFINCLUDE to include another .cfm page that has a list of groups that a user belongs to, and a form field that will allow an admin to add a group to a user's list.  It's a select drop-down with an ADD button.  The admin should be able to add a group to the user's list without refreshing the page, so I'm using AJaX to submit the data to a cfc; the cfc query runs (successfully adding the group), and returns either a 1 for success, or anything else for a fail.

       

      If a 1 is returned, I'm trying to use jQuery.load() to refresh the data in the div surrounding the CFINCLUDE.  But the div becomes empty, and even FireBug is showing that the GET from the .load() is returning nothing.

       

      Some sample pseudo-code:

       

      Parent page (records.cfm):

       

      <div id="rec_adminlist"><cfinclude template="rec_adminlist.cfm" /></div>
      <script type="text/javascript">
      function reloadDiv(divObj,pg){divObj.load(pg);}
      </script>
      

       

      Child page (rec_adminlist.cfm):

       

      <select id="adminList"> ...</select><input type="button" value="Add" id="submitBtn" />
      <script type="text/javascript">
           $('#submitBtn').click(function(){
                var $rec_adminlist = $('#rec_adminlist');
                $.post("/url/to/cfc/mycfc.cfc?method=addToAdminList",
                          {adminID: $('#adminList').val(), userID: "#userID#"}
                          ).fail(blah blah blah).always(function(data){
                                                                  switch(data){
                                                                       case '1':
                                                                            reloadDiv($rec_adminlist,'rec_adminlist.cfm');
                                                                       break;
                                                                       }
                                                                  }
                                                                  );
                });
      </script>
      

       

      The INSERT into the database is successful; but the .load() brings back blank.  If I refresh the page, the new data is displayed.

       

      I've never had a problem loading a .cfm page via AJaX, before.  Why is this returning blank?

       

      V/r,

       

      ^_^