1

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

PHP

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

Using this Ajax POST:

JS

function showLoader(){
    $.ajax({
        type: "POST",
        url: baseUrl+"/requests/get_Logo.php",
        dataType : 'html',
        cache: false,
        success : function(html){
            $('#content-loader').html($(html.content).text());
        }
    });
}

get_Logo.php

<?php
include("../includes/config.php");
include("../includes/classes.php");

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

Is there any chance to make it works?

NineCattoRules
  • 2,253
  • 6
  • 39
  • 84
  • Possible duplicate of [Load HTML page dynamically into div with jQuery](http://stackoverflow.com/questions/14735762/load-html-page-dynamically-into-div-with-jquery) – Ozan Aug 07 '16 at 23:08
  • @Ozan I don't think it's a duplicate, my problem here is related to an Ajax POST – NineCattoRules Aug 07 '16 at 23:14

1 Answers1

4

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) {
    $('#content-loader').html(html);
Zayn Ali
  • 4,765
  • 1
  • 30
  • 40