I am trying to call a javascript function from php code, which it will receive a php variable from an input form. Once Javascript function received this variable or value it will call a php (search.php file) to make a query and other jobs.
PHP code:
<?
I need to call search function in php passing the $_POST Global variable value :
something like this: <script> search($_POST) ; </script>
?>
Javascript file name: call_search.js:
function search($_POST or variable) {
var search_query = $(this).val();
$.post('search.php', {search_query : search_query}, function(searchq) {
$('#search_query').html(searchq);
});
}
Nota: search.php is another php file doing mysql query and others jobs which it send back the result: MySQL query back to Javascript function.
Any help ..Please.!! Thank you very much.