2

I have a php file tha gives me the ossibility of displaying a pdf file from mysql now I want to display that pdf in a div in html file this is my function in javascript var id;

function displayNotes() {
    //id=localStorage.getItem("userid");
    id = 160;
    var urlString = "id=" + id;
    $.ajax({
        url : "http://localhost/notePdf.php",
        type : "GET",
        cache : false,
        data : urlString,
        success : function(response) {
            console.log(response);
            document.getElementById("pdf").innerHTML = response;

        }
    });
}

and this is my div in html

<div class="content">
                        <div id="form">
                            <form action="" id="contactForm" method="post">
                                <span>Email</span>
                                <input type="text" name="email" class="email" placeholder="Enter your email" tabindex=2 />
                                <span>Email</span>
                                <input type="text" name="email" class="email" placeholder="Enter your email" tabindex=2 />
                                <span>Message</span>
                                <textarea class="message" tabindex=4 id="pdf"></textarea>
                                <input type="submit" name="submit" value="Send e-mail" class="submit" tabindex=5>
                            </form>
                        </div>
                        </div>
Amal
  • 75
  • 1
  • 2
  • 11

1 Answers1

1

use embed tag instead of text area if your using javascript to create it use DOM nodes to create an embed tag and ad the location as the src

<embed id = 'pdf' src="(location to your pdf file)"></embed>

in js:

document.getElementById("pdf").src = response;
Chris Hutchison
  • 601
  • 6
  • 20