AJAX result is gone when print the page

when I try to print the page, some data are gone as you can see from the below examples.

All data that are missing is retrieved by AJAX method.

I believe this is because web browser calls the page again when window.print() method is called and render earlier than ajax is called.

Because every now and then the data shows, but not always.

How can I make sure that print preview is rendered after every ajax method in DOM is called?

Result on Webpage Result when print preview]


This is the server part. When a user requests "/evaluation/silver/userinfo" url, my.html will be rendered and ajax is called in my.html where the ajax code is located.

from models.restful_api import *
api.add_resource(UserInfo, "/evaluation/silver/userinfo")

def SilverEvaluation_new():
    return render_template('folder/my.html')

And below is the ajax function that calls API.

    $(function() {
        type: "get",
        url: "/evaluation/silver/userinfo",
        data: 'application/json',
        success: function(data){
            var name, user_birth, bodycheck_date, gender, score, how_many;
            name = JSON.parse(data).name;
            user_birth = JSON.parse(data).birth;
            bodycheck_date = JSON.parse(data).check_date;
            gender = JSON.parse(data).gender;
            if (gender === "M"){
                gender = "남"
            } else {
                gender = "여"
            score = JSON.parse(data).score;
            how_many = JSON.parse(data).how_many;