mysql - Why do I obtain always error with ajax into my php web page? -
i want delete record database , want use ajax..
so have table put last td
this:
<input type='image' src='./img/delete.png' onclick='deleteuser(".$utentiiscritti[$i][0].");' />
this deleteuser
function:
function deleteuser(id){ $.ajax({ type:"post", url: "deleteuserajax.php", data: {'id':id}, success: function(data){ console.log("ok"); location.reload(); }, error: function(xhr, status, error){ alert(xhr+"\n\n"+status+"\n\n"+error); console.log("ko"); } }); }
and php page connect db , delelte record:
<?php $userdb = "u"; $passworddb = "p"; $namedb = "d"; $querydeleteuser = 'delete user id = "'.$_post['id'].'"'; $conn = mysql_connect("localhost", $userdb, $passworddb) or die("errore nella connessione al database: " . mysql_error()); mysql_select_db($namedb) or die("errore nella selezione del database: " . mysql_error()); mysql_query($querydeleteuser) or die("errore nella query: " . $querydeleteuser . "\n" . mysql_error()); dbdisconnect($conn);
but obtain (from every ajax request) error:
failed load resource: server responded status of 500 (internal server error) iscritti.php:80
why???
you can consider 2 solutions.
- your code buggy. try execute on it's own. call in browser , check result!
- you have specified relational path script.
url: "deleteuserajax.php"
, try instead absolute path , check result (url: "http://yourdomain.com/deleteuserajax.php"
)
Comments
Post a Comment