Loading ...
Sorry, an error occurred while loading the content.

Re: how to use ajax to load content into a panel

Expand Messages
  • bretlevy
    Chad: If the scripts return actual HTML (snippets), just take the responseText from the async call return object and place it in a div on the panel. If this is
    Message 1 of 6 , Jan 30, 2008
    • 0 Attachment
      Chad:

      If the scripts return actual HTML (snippets), just take the
      responseText from the async call return object and place it in a div
      on the panel.

      If this is your call to get the content, for example:

      YAHOO.util.Connect.asyncRequest("POST", "getcontent.php",
      {success:updatePanel}, "ID="+id);

      Then in your handler, do this:

      function updatePanel (txdata) {
      YAHOO.util.Dom.get('mydiv').innerHTML = txdata.responseText;
      }

      This is very abbreviated, but that's the basic idea. To "clear" the
      contents, like when the panel is closed or opened, just set the
      innerHTML to "" (an empty string).

      'mydiv' is the id of the <div> in the panel you want to update.

      I recommend that your server content-scripts return a content type of
      text/plain even though the content is (might be) HTML. I've found
      that solves a lot of issues (especially when debugging).

      ~~bret




      --- In ydn-javascript@yahoogroups.com, "chad_h_" <chad.horton@...>
      wrote:
      >
      > Hello,
      >
      > I have a page that I'd like to use Panel and Connect.asyncRequest.
      I'd
      > like to use a single panel and then load content from the ajax call
      > into the panel.
      >
      > I'd have n number of links that the user can click on, each one
      making
      > a call to a script (and passing the id) for which the script will
      > return content based on that id. Then the results will be
      displayed
      > into that panel and the panel will show.
      >
      > when the panel is closed as well as when the panel initialized upon
      > page load, the body will be empty/null and will be hidden.
      >
      > Any help would be greatly appreciated. I've tried a lot of
      different
      > methods based on the examples on the site and none of them have
      worked.
      >
      > Thanks!
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.