The problem you have "roughly" has no solution. Both the JavaScript code and the HTML code is processed by the PHP kernel that after processing it generates it and the browser shows it to you. Example:
$a = "<h1>hola</h1>";
With this code, the PHP kernel will generate the following document, which is what it will send to the browser:
<html>
<head></head>
<body>
<h1>hola</h1>
</body>
</html>
What I mean is that you can not try to enter JavaScript variables in PHP code with the intention that this process the value of the JavaScript variable, since PHP will generate the JavaScript variable as is so that the browser uses it together your JavaScript code
That is, you can not pass a JavaScript variable to the PHP function and expect it to recognize the value and use it.
Now, in your specific case, the following may work for you:
$(document).on('click','.view-info',function(){
id_ = $(this).val();
url = '<?php site_url("Venta/detail/") ?>' + id_;
This in the document that PHP generates would be something like:
$(document).on('click','.view-info',function(){
id_ = $(this).val();
url = 'lo_que_la_función_php_site_url_genere' + id_;
If this last one does not work for you, I doubt you can do what you want, you will surely have to change the approach of your program. If you provide more information about what you want to do with your program, we may be able to help you.