Skip to content Skip to sidebar Skip to footer

Attempting To Load A "div" As Dynamic Content Is Returned

I have a PHP program which performs a series of key driven SSH connections (as Apache user www-data), and executes scripts on the remote server which check the statuses of a couple

Solution 1:

So a very simple example of how to dynamically add content to a DOM element. You can use $.ajax

var request = $.ajax({
      type: "POST",
      url: "example.php",
      data: data_obj,
      dataType: "html"
   }).done(function(msg) {
         $("#example_element").append(msg);
      }

the url: will point to your file.

data: is optional, but using that option will allow you to pass the key you want to retrieve back.

dataType: specifies what return type you expect

in .done the simplest thing you can do to load content is just to append it to something (or replace, but in your case you probably want to append it).

Note that this call doesn't check for error cases.

The documentation is pretty verbose but you should still read it if you plan on using AJAX calls.

Post a Comment for "Attempting To Load A "div" As Dynamic Content Is Returned"