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.

  1. your code buggy. try execute on it's own. call in browser , check result!
  2. you have specified relational path script. url: "deleteuserajax.php", try instead absolute path , check result (url: "http://yourdomain.com/deleteuserajax.php")

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -