Error In Ajax Insert Database
In each row, i want to add a editable td to insert 'mavandon' into DATABASE dsdonhang. I read this on http://phppot.com/php/php-mysql-inline-editing-using-jquery-ajax/ but it doesn
Solution 1:
use onblur
instead of onchange
<tdcontenteditable="true"onblur="saveToDatabase(this,'mavandon','<?phpecho$madon; ?>')"onClick="showEdit(this);"><?phpecho$data[$k]["mavandon"]; ?></td>
Solution 2:
Typo / incorrect while passing params in the ajax call. Modify it as mentioned below
add this in ajax call. '&idd='+idd Instead of this '&idd='+$(this).idd
Solution 3:
Make sure that ur event is getting called.(u can check in firebug also.) Pass parameters as {column: $(this).column,editval:$(this).editableObj.innerHTML,idd:$(this).idd}
Solution 4:
Try this:
<script>
$(document).ready(function(){
functionsaveToDatabase(editableObj,column,idd) {
var data = {'column':$(this).column,'editval':$(editableObj).text(),'idd':$(this).idd };
$.ajax({
url: "saveedit.php",
type: "POST",
contentType: "application/json; charset=utf-8",
datatType: "json",
data:JSON.stringify(data),
success: function(data){
$(editableObj).css("background","#FDFDFD");
console.log("received data=>"+data);
alert ("hello");
}
error: function(err) {
console.log("error=>"+err); //print error if exist
}
});
}
});
</script>
Post a Comment for "Error In Ajax Insert Database"