简体   繁体   中英

load ajax url on new page?

在此处输入图片说明 i know this question is not asked well & iam sorry for that

given requirement is that url shoul be open in _blank page but i have design ajax url is it possible ajax url is open in new page? like regular url other wise i have to change lots of things here is the code

  function pdfPrint(start_date , end_date , view){

    var startDate = $('#setDate-'+start_date).val();
    var endDate = $('#setDate-'+end_date).val();       
    data = {
            "startDate":startDate,
            "endDate":endDate,
            "view":view,
            "systemid":system_id,
        };
    $.ajax({
        url: "{{route('download.pdf')}}",
        type: "get",
        'headers': {
          'X-CSRF-TOKEN': '{{ csrf_token() }}'
        },
        data:data,
    }).done(downloadFile);       
}

this simple trick to open window and exec js code;

let js = `<script>
    function pdfPrint() {
        window.print();
    }
    
    // exec your function
    pdfPrint();</` + `script>`;

let win = window.open("", "MsgWindow", "width=400,height=400");
win.document.write(js);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM