skip to Main Content

I’m creating a pos billing system in laravel, I send request by ajax to router controller, and i want to in ajax response, he redirect another page with some data for display in invoice.

My function work properly , in my browser network section, in preview have display invoice , but I want to this invoice open in another page .

enter image description here

my ajax code

enter image description here

billPrint function in controller

enter image description here

I’m trying to my invoice page open in another page , currently invoice page open in response .

2

Answers


  1. let yourPageUrl = 'your_new_view';
    let yourAjaxResponseHtml = "<h1>Hello World</h1>";
    let newWindow = window.open(yourPageUrl, '_blank');
    newWindow.document.write(yourAjaxResponseHtml);
    newWindow.document.close();
    
    Login or Signup to reply.
  2. In order to open the invoice in another page you do not need to use ajax.

    Simply opening a new browser tab from javascript, and setting the tab’s source to your controller would be fine:

    // Composing the url with the parameters
    const invoicePrintUrl = 
      "{{ url('admin/billing/print') }}" + 
      '/' + billNumber +
      '?' + 'billNumber=' + billNumber +
      '&' + 'customer_points=' + customer_points +
      '&' + 'isPointUsed=' + isPointUsed;
    
    // Opening the new browser tab
    window.open(invoicePrintUrl, "_blank");
    

    (Insert the above code snippet in place of the ajax call in the index.blade.php)

    Your billPrint controller already worked fine and you were able to see it the network preview tab because your controller responded with the rendered view and the preview tab displayed that response.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search