How to pass .html () value from JavaScript to CodeIgniter controller?

I have a print button, and when I click on it, the following JavaScript function should start.

$('.print').click(function(){ var htmlval=$('.pop_reciept').html(); window.open('http://localhost/ccccccc/xxxxxxx/pdf/'+htmlval,'_blank'); }); 

htmlval contains HTML elements with class pop_reciept , and then pass this to the pdf controller:

 public function pdf($val){ echo $val; return false; } 

I want the HTML content to display. But this is not so, and instead I see an error

The URI you submitted has illegal characters.

Please help or suggest a better way to do this.

+4
source share
2 answers

The URL size is limited to 8kb on most servers, and large snippets of html code can easily exceed it.
Sending a POST request instead also solves the problem of invalid characters.
You can find a solution for this here: Window.open and pass parameters using the post method

+2
source

add special characters to the $config['permitted_uri_chars'] variable

 $config['permitted_uri_chars'] = 'az 0-9~%.:_=+-'; 

in config.php file

0
source

Source: https://habr.com/ru/post/1445028/


All Articles