We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Using Ajax while saving

Can anyone give me a simple example of using ajax to save with parameters using PDF Viewer. I noticed while reading the API docs something called  AjaxRequestSettings. Can anyone give me an execution example?


2 Replies

FA Farai November 3, 2022 05:04 AM

I have seen somewhat of an example but do not have the full picture.



CK Chinnamunia Karthik Chinna Thambi Syncfusion Team November 3, 2022 06:12 AM

AjaxRequestSettings is used to set the custom AJAX request header values of the PDF Viewer AJAX requests. If you want to send the custom JSON data in the AJAX request parameter while saving the document or any other request, use the below code snippet.



Code Snippet:


    function ajaxRequestInitiate(args) {

        var viewer = document.getElementById('pdfviewer').ej2_instances[0];

        if (args.JsonData['action'] == 'Download') {

            args.JsonData['name'] = "Syncfusion";

            args.JsonData['userId'] = "User1";

            viewer.setJsonData(args.JsonData);

        }

    }


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/setJsondata-1736856744.zip


Documentation: https://ej2.syncfusion.com/documentation/api/pdfviewer/#setjsondata


Loader.
Live Chat Icon For mobile
Up arrow icon