How to fix a Jquery script that uses a Webservice to upload a file

Asked

Viewed 29 times

2

I am trying to save a PDF file to my server folder using a Webservice. I think this should be a simple task, but after searching a lot on the WEB I discovered the script below but when I run it is getting the error "Internalerror: Too Much recursion". This error occurs in jquery.min.js

function salva2(quality = .10) {
        const filename = 'ThisIsYourPDFFilename.pdf';

        html2canvas(document.querySelector('#renderPDF'),
            { scale: quality }
        ).then(canvas => {
            let pdf = new jsPDF('p', 'mm', 'a4');
            window.onePageCanvas = document.createElement("canvas");
            window.onePageCanvas = canvas.toDataUR;
            pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0, 211, 298);
            //pdf.save(filename);


            jQuery.ajax({
                url: '/WebserviceFace/UploadFile',
                type: 'POST',
                contentType: 'application/pdf; charset=utf-8',
                dataType: 'pdf',
                data: {
                    fileName: 'Teste1',
                    contentType: 'pdf',
                    bytes: pdf,
                },
                error: function (request, status, error) {
                },
                sucess: function (data, status, request) {
                }
            })
        });
    }

Someone can point out to me what I am doing wrong. Please point out to me what I am doing wrong.

Thank you in advance

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.