I don't understand this code should make an editable table but I have a but on a } and I see nothing. Everything match. the code is: http://www.dollarannonce.com/Cmaisonneuve/Client-serveur/TP2/Ajax-POO/index.php
The index.php code is:
<html>
<head>
<script type="text/javascript"src="http://code.jquery.com/jquery-latest.js"> </script>
<script>
function showEdit(editableObj) {
$(editableObj).css("background","#FFF");
}
function saveToDatabase(editableObj,column,id) {
console.log(column+" : "+id);
$(editableObj).css("background","#FFF url(loaderIcon.gif) no-repeat right");
$.ajax({
url: "saveedit.php",
type: "POST",
data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,
success: function(data){
$(editableObj).css("background","#FDFDFD");
}
});
}
</script>
<script>
var titre11 = 'titre';
$.ajax({
url: 'jsonTable2.php',
type: 'GET',
dataType : 'json',
/*data: {
json: jsonData
},*/
success: function (response) {
//alert('toto');
//alert(response);
//console.log(response);
//response = $.parseJSON(response);
var trHTML = '';
//alert('allooo');
$.each(response.livres, function (id,item) {
trHTML += '<tr><td contenteditable="true" onBlur="saveToDatabase(this,"titre",'+item.id+')" onClick="showEdit(this);">' + item.titre + '</td>';
trHTML += '<td contenteditable="true" onBlur="saveToDatabase(this,"auteur",item.id)" onClick="showEdit(this);">' + item.auteur + '</td>';
trHTML += '<td contenteditable="true" onBlur="saveToDatabase(this,"annee",item.id)" onClick="showEdit(this);">' + item.annee + '</td>';
trHTML += 'td contenteditable="true" onBlur="saveToDatabase(this,"isbn",item.id)" onClick="showEdit(this);">' + item.isbn + '</td>';
trHTML += '<td contenteditable="true" onBlur="saveToDatabase(this,"editeur",item.id)" onClick="showEdit(this);">' + item.editeur + '</td>';
trHTML += '<td contenteditable="true" onBlur="saveToDatabase(this,"titre",item.id)" onClick="showEdit(this);">' + item.evaluation + '</td></tr>';
});
$('#records_table').append(trHTML);
}
});
</script>
</head>
<body>
<table id="records_table" border='1'>
<tr>
<th>Titre</th>
<th>Auteur</th>
<th>Année</th>
<th>Isbn</th>
<th>Éditeur</th>
<th>Évaluation</th>
</tr>
</table>
</body>
</html>
I don't understand why the code doesn't work. Every { as is } there is no extra.
the script that writes the table is all messed uptrHTML += 'td contenteditable="true" onBlur="saveToDatabase(this,"isbn",item.id)" onClick="showEdit(this);">'
it will create a onBlur="saveToDatabase(this," and a bunch of junk on a tag, not to mention you're missing the pulp fiction bracket in this line in particular. pulp fiction wtf? it's the "< >". fix this script and then your onblur should start to work (or crash properly at least).