Display PDF using an AJAX call

前端 未结 4 1725
广开言路
广开言路 2020-12-03 01:39

I\'m trying to display a PDF(which is created in the server side and pass to the client side as a web stream) through an AJAX call. My code is given below:

j         


        
4条回答
  •  不知归路
    2020-12-03 02:31

    Why do you load it via AJAX? Why don't you load it in an IFRAME that you generate when you need it. The standard browsers plugin will display it then inside that Iframe.

    $('#link').click(function(e) {
        e.preventDefault(); // if you have a URL in the link
        jQuery.ajax({
            type: "POST",
            processData: false,
            url: "aaaa.p?name=pdf",
            data: inputxml,
            contentType: "application/xml; charset=utf-8",
            success: function(data)
            {
                var iframe = $('