Good evening.
There is such a simple AJAX script:
function go_news ( id ) { var go_id = id; var search = 'id_go'; $.post('site.php', { go_id: go_id, search: search }, function(data){ $('#info').html(data); }); return false; }; And php file:
if ($_POST['search'] == 'id_go') { //Замена $go_id = str_replace('', '', $_POST['go_id']) //И так далее //а тут уже конечный ответ к примеру echo $go_id; } How to make that when functions were performed in php, I had the answer in the form of text, what stage is being performed in
<div id="info">Тут ответ и результат потом уже</div> ?
I have a function for php, and I can't figure out how to use it with AJAX.
function printJson($info, $error = false) { @header( 'Content-Type: text/html; charset=UTF-8' ); if (!$error) { echo $info; return null; } $json = array( 'text' => '<span>' . $info . '</span>' ); echo json_encode( $json ); exit( ); }