php - Request new page with ajax and open it in new page -


i'm having problem trying request new page(s) codeigniter using jquery ajax , open them in new blank page

the following example scenario of current code working,

1.) user select customer's receipt checkbox

<input type='checkbox' class='customer_id' value='<?php echo $entry->customer_id;?>'> 

2.) javascript read customer(s) id send data codeigniter. once return data received, fire callback function display them target div

var data; var counter = 1; $(.customer_id:checked).each(function(){     data['customer_' + counter] = $(this).val(); })     $.post('finance/getreceipt', data, function(){     $('#some_target_div').html(data); } 

3.) codeigniter retrieve customer data db , generate page

function getreceipt(){     $counter = 1;     while ($this->input->post('customer_' + $counter)){         $where['customer_id'] = $this->input->post('customer_' + $counter);         $data += $this->getcustomerreciept($where);     }     $this->load->page('finance/receipt', $data); } 

but need convert code make open new blank page print button

the purpose of because want generate formatted receipt , display in new blank page print button. know there several plugin can print div request client. so, that's isn't solution me.

any suggestion or comment great. thank in advance.

i think easiest way create auxiliar form post data new page instead of using $.post so, code:

var data; var counter = 1; $(.customer_id:checked).each(function(){     data['customer_' + counter] = $(this).val(); }); $('<form action="finance/getreceipt" method="post" target="_blank" style="display:none">' + '<input type="hidden" name="data1" value="value-data1" />' ).appendto("body").submit().remove(); 

just change data1 param 1 want, or add more if want. , that's it. magic in using _blank target form.

hope helps. cheers

ps: other way creating new window window.open , assign content javascript.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -