I want to get a string in a PHP file called search.php I want to return a string for my index.php but I want to do this when calling the try_it () function, is there any way I can do this with jQuery? I do not want index.php to update the page, only the value of the variable that will be returned by the search.php
index.php
<html>
<head>
<title>teste</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script><!--LatestcompiledandminifiedCSS--><linkrel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<body>
<button class="btn btn-default" id="executar" onclick="buscar()" type="button">Buscar</button>
<script>
var stringDoPHPvemPraCa;
function buscar(){
//quero que a string do php seja setada em stringDoPHPvemPraCa no momento em que eu chamar essa funcao
}
</script>
</body>
</html>
search.php
include 'config.php';
include 'database.php';
include 'connection.php';
$pesquisa = DBSearch("usuarios","WHERE id = 1","questoes_resolvidas"); // isso me retorna um array
// com as questões resolvidas onde "usuarios" é a tabela "WHERE id = 1"
// é o parametro e "questoes_resolvidas" é o campo a ser retornado (a string em si)
$pesquisa[0]['questoes_resolvidas'] //isso que eu quero no index.php