I am trying to improve my jQuery and AJAX knowledge and I wanted to create a simple call to my database. However, I am having some issues with it and I can't really understand why. Here is the code:
function provaajax() {
$.ajax({
url: 'visualizza.php',
data: "",
dataType: 'text',
complete: function(data) {
var nome = data[0];
var cognome = data[1];
$('.provajax').html("<b>nome: </b>" + nome + "<b> cognome: </b>" + cognome);
}
});
}
And here is my PHP file:
<?
Connection();
$result = mysql_query("SELECT * FROM prova WHERE ID = 117");
$array = mysql_result($result, 0, "Nome");
$array = mysql_result($result, 0, "Cognome");
echo $array;
?>
And a little code from my HTML:
<div>
<button onclick="provaajax()">Prova Ajax</button>
<p class="provajax"> Hello world </p>
</div>
But this code isn't working. I don't know how to use JSON, so it would be better not to use it. Any ideas?