Simone Simone - 1 year ago 142
Javascript Question

How to append HTML string to div via Ajax

I really have big difficulties with Ajax, this time I'm not able to append some HTML code to a div.

I need to append to

<div id="content-loader"></div>
this HTML string


function getLogo(){
$logo = '<div class="bg-logo-loading"></div>
<div class="logo-loading-container">
<div class="logo-loading-inner">
<div class="logo-loading">
return $logo;

Using this Ajax POST:


function showLoader(){
type: "POST",
url: baseUrl+"/requests/get_Logo.php",
dataType : 'html',
cache: false,
success : function(html){



$feed = new feed();
echo $feed->getLogoLoading();

Is there any chance to make it works?

Answer Source

You are getting html in response then simply just put it inside of your content-loader div using jQuery's html method. like this

success : function(html) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download