Hello.
There is an html table in admin page, with head columns (POST ID | POST TITLE | POST AUTHOR | ACTION).
And in each row, will contain a post id, a post title, a post author that gets from database.
And in the Action column, there is a "delete" word that is a link with href="#" for now.
I want the script when i click on the delete word in each rows, erase that row of data from the table of the database and from the html table.
I don't know how should i do that. Just need guidance to understand what i can do for that, thank you.
Niloofar24 15 Posting Whiz
Edited by Niloofar24
lps 71 Posting Pro in Training
In your action link, add an the link with id attribute like<a id="<?php echo $post['id'] ?>" href="#">Delete</a>
Then using an ajax to delete the row of data based on the link id's post['id'] and when successful, find the parent of the link again using the same id attribute and remove the row.
Niloofar24 15 Posting Whiz
@lps, your explanation was good but would you please explain it one more time but a little more clear please?! Sorry i didn't understand what should i do exactly well (just because my english is not good enough, so sometimes i have to ask friends to explane one more time and more clear to get the point better, thank you:) ).
Edited by Niloofar24
Niloofar24 15 Posting Whiz
specially i didn't understand this part
find the parent of the link again using the same id attribute and remove the row.
lps 71 Posting Pro in Training
I don't know your code structure but if you are using a table, then the code will be like
<table>
<tr class="tr">
<td>Post ID</td>
<td>Post Title</td>
<td>Author</td>
<td><a class="btn_dlt" id="<?php echo $post['id'] ?>" href="#">Delete</a></td>
</tr>
</table>
$(document).ready(function(){
$("btn_dlt").click(function(){
$.ajax({
type: "POST",
url: "./process.php",
data: { id: $(this).attr("id") }
}).done(function( msg ) {
if(msg == "Success"){
$(this).closest('.tr').remove();
}
});
});
});
in your process.php, you should echo "Success" when successful for the ajax to compare the result as from my code.
lps 71 Posting Pro in Training
Sorry, I found my scripting having some mistake
$(document).ready(function(){
$(".btn_dlt").click(function(){
var id = $(this).attr("id");
$.ajax({
type: "POST",
url: "./process.php",
data: { id: id }
}).done(function( msg ) {
if(msg == "Success"){
$(this).closest('.tr').remove();/*using the clicked button to find the element to delete*/
/*$("#"+id).closest('.tr').remove();using the id to find the element to delete*/
}
});
});
});
Niloofar24 15 Posting Whiz
This is my code:
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT ID, Title, Author, Content FROM Posts";
$result = $conn->query($sql);
echo "<table cellspacing='0' cellpadding='20' border='1px solid black' border-collapse='collapse'>";
echo "<tr><th> POST ID </th><th> POST TITLE </th><th> POST AUTHOR </th><th> ACTION </th></tr>";
foreach($result as $row) {
echo "<tr><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <a href='#'>Delete</a> <br> <a href='#'>Edit</a> </td></tr>";
}
echo "</table>";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
<html>
<head>
<title>admin</title>
</head>
<body>
<hr>
<?php echo "<a href='writing-post.php'>writing new post</a>"; ?>
</body>
</html>
Niloofar24 15 Posting Whiz
@lps would you please explain your code with comments?
Niloofar24 15 Posting Whiz
Well i have added this part below, after line 24:
if(isset($_POST['submit'])) {
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$id = $_GET['POST'];
$sql = "DELETE FROM Posts WHERE ID = '$id'";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':title', $title, PDO::PARAM_STR);
$stmt->bindParam(':author', $author, PDO::PARAM_STR);
$stmt->bindParam(':content', $content, PDO::PARAM_STR);
$stmt->execute();
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
}
?>
And have changed this part:
foreach($result as $row) {
echo "<tr><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <a href='#'>Delete</a> <br> <a href='#'>Edit</a> </td></tr>";
}
into this:
foreach($result as $row) {
echo "<tr><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <input type='submit' name='submit' value='Delete'" .$row['ID']. "> <br> <a href='edit-page.php?post=" . $row['ID'] . "'>Edit</a> </td></tr>";
}
But it doesn't work. When i click on Delete button, it doesn't clear anything from db table. It seems the Delete button can't send the post's id to the script to find the exact row of the table that should be delete.
Niloofar24 15 Posting Whiz
Any more suggestion for how to edit this code to work? Every guidance is welcome.
Eagle.Avik 0 Junior Poster in Training
there is some problem with your script
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword
specially how are you using $servername
and $dbname
inside quote!! shouldn't it be:
$conn = new PDO("mysql:host=".$servername.";dbname=".$dbname, $dbusername, $dbpassword
cause i thought variables don't work inside wuote unless you are using double quote with single quote!
Eagle.Avik 0 Junior Poster in Training
also should not you use html form
<input type='submit' name='submit' value='Delete'" .$row['ID']. ">
how are you submitting it, are you using ajax and jquery??
as +lps mentioned, you should use ajax to call the script or use form.
here is a sollution:
you should probably use:
<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>" >
<input type='hidden' name='row_no' value=".$row['ID']." />
<button class="btn_dlt" name='submit'>Delete</button>
</form>
and for PHP:
if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['row_no'] !== null) {
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
$id = $_POST['row_no'];
try {
$conn = new PDO("mysql:host=".$servername.";dbname=".$dbname."", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "DELETE FROM Posts WHERE ID = `:id`";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
}
it should work, i didn't test it, so if it shows some error, let me know.
Edited by Eagle.Avik
Niloofar24 15 Posting Whiz
@Eagle.Avik, so you means i should use this? The way i used was incorrect?
$conn = new PDO("mysql:host=".$servername.";dbname=".$dbname, $dbusername, $dbpassword
as +lps mentioned, you should use ajax to call the script or use form.
You said i shouldn't use that submit button whi Delete value, and you gave a form part instead. But where i should use that? In that echo part that i put Delete button before?
Edited by Niloofar24
Niloofar24 15 Posting Whiz
This is my last code changes:
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT ID, Title, Author, Content FROM Posts";
$result = $conn->query($sql);
echo "<table cellspacing='0' cellpadding='20' border='1px solid black' border-collapse='collapse'>";
echo "<tr><th> POST ID </th><th> POST TITLE </th><th> POST AUTHOR </th><th> ACTION </th></tr>";
foreach($result as $row) {
echo "<tr><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <a href='admin.php?post=" . $row['ID'] . "'>Delete</a> <br> <a href='edit-page.php?post=" . $row['ID'] . "'>Edit</a> </td></tr>";
}
echo "</table>";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
if($_GET['POST']){
$servername = "localhost";
$dbname = "blenderl_CMS";
$dbusername = "blenderl_nilofar";
$dbpassword = "andishe#n";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$delete_id = $_GET['POST'];
$sql = "DELETE FROM Posts WHERE ID = '$delete_id'";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':title', $title, PDO::PARAM_STR);
$stmt->bindParam(':author', $author, PDO::PARAM_STR);
$stmt->bindParam(':content', $content, PDO::PARAM_STR);
$stmt->execute();
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
}
?>
<html>
<head>
<title>admin</title>
</head>
<body>
<hr>
<?php echo "<a href='writing-post.php'>writing new post</a>"; ?>
</body>
</html>
But it doesn't work. I tried to send each post's id by using <td> <a href='admin.php?post=" . $row['ID'] . "'>Delete</a>
(admin.php is the address of this page) to this part if($_GET['POST']){
.
Why it doesn't work?
Niloofar24 15 Posting Whiz
Nobody can help me with this problem?! No more suggestion?
I have sent my last update that still doesn't work.
Niloofar24 15 Posting Whiz
This is my last update, i tried to use the script of this link, (look at PHP File: deletephp.php there), but it didn't work for me.
Mine:
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT ID, Title, Author, Content FROM Posts";
$result = $conn->query($sql);
echo "<h1>Welcome to Admin area</h1>";
echo "<table cellspacing='0' cellpadding='20' border='1px solid black' border-collapse='collapse'>";
echo "<tr><th> POST ID </th><th> POST TITLE </th><th> POST AUTHOR </th><th> ACTION </th></tr>";
foreach($result as $row) {
echo "<tr><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <a href='admin.php?del={" . $row['ID']. "}'><input type='button' class='submit' value='Delete'></a>";
}
echo "</table>";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
if (isset($_GET['del'])) {
$servername = "localhost";
$dbname = "blenderl_CMS";
$dbusername = "blenderl_nilofar";
$dbpassword = "andishe#n";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$del = $_GET['del'];
$sql = "DELETE FROM Posts WHERE ID = :del";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':del', $del, PDO::PARAM_STR);
$stmt->execute();
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
}
?>
Edited by Niloofar24
Niloofar24 15 Posting Whiz
My last code changes is:
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT ID, Title, Author, Content FROM Posts";
$result = $conn->query($sql);
echo "<h1>Welcome to Admin area</h1>";
echo "<table cellspacing='0' cellpadding='20' border='1px solid black' border-collapse='collapse'>";
echo "<tr><th> POST ID </th><th> POST TITLE </th><th> POST AUTHOR </th><th> ACTION </th></tr>";
foreach($result as $row) {
echo "<tr><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <a href='delete-action.php?id=" . $row['id'] . "'> delete </a></td></tr>";
}
echo "</table>";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
And this is delete-action.php file:
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$id=$_GET['id'];
$sql = "DELETE FROM Posts WHERE ID = :id";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':id', $id, PDO::PARAM_STR);
$stmt->execute();
header("location: admin.php");
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
I have used this link, it should works but it didn't!... Is there anyone to help me with that??!!
Edited by Niloofar24
lps 71 Posting Pro in Training
Try modify your delete-action.php into:
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$id=$_GET['id'];
$sql = "DELETE FROM Posts WHERE ID = '$id'";
$conn->exec($sql);
header("location: admin.php");
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
after the delete-action.php, you check the database manually and view if the data deleted. As the browser maybe caching the data of your admin.php and not querying latest of it.
but if I am in the case, I will not using redirecting and links since it is CMS, so I will use ajax to do the task without refreshing the page. First, include the javascript for the ajax.
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script><!--This is to include the jquery js for ajax to work, you can download it for better performance-->
<script>
//made sure the script only be bounded after all element being loaded
$(document).ready(function(){
$(".btn_dlt").click(function(){ // bind the function when the element with class btn_dlt is clicked
var btn_dlt = $(this); //assign the clicked button into a variable for later usage
$.ajax({
type: "POST",
url: "./delete-action.php", //post the data to delete-action.php
data: { id: btn_dlt.attr("id") } //set the id as data
}).done(function( msg ) { //when the ajax done(the return of the delete-action.php will be set into msg
if(msg == "Success"){
/*using the clicked button to find the nearest parent with the class name to delete*/
btn_dlt.closest('.tr').remove();
}else{
$('#err_msg').html(msg); //to write the message into err_msg field
}
});
});
});
</script>
Then the php loop for your html layout.
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT ID, Title, Author, Content FROM Posts";
$result = $conn->query($sql);
echo "<h1>Welcome to Admin area</h1>";
echo "<p id='err_msg'></p>";//add this line for error message display, may add styling to this for bold and red color words
echo "<table cellspacing='0' cellpadding='20' border='1px solid black' border-collapse='collapse'>";
echo "<tr><th> POST ID </th><th> POST TITLE </th><th> POST AUTHOR </th><th> ACTION </th></tr>";
foreach($result as $row) {
echo "<tr class='tr'><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <a id='".$row['ID']."' class='btn_dlt' href='#'> delete </a></td></tr>";
}
echo "</table>";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
and finally the modified delete-action.php which will delete the row from db and response to ajax.
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$id=$_POST['id'];
$sql = "DELETE FROM Posts WHERE ID = '$id'";
$conn->exec($sql);
echo "Success"; // the word here must be same as ajax comparism
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
Niloofar24 15 Posting Whiz
Yesss :) It works! Thank you @lps.
I used the ajax part, the php loop for the html layout and the delete-action.php.
I have some questions.
First, i thought with the ajax part, when i click the delete link, data will be deleted from db and also from html table at the same time, but when i click, data will be deleted from db and a success message will be printed above the html table at the same time.
Now i have to refresh the page to update the html table. Can i do that with macking changes in the ajax code you typed above?
And would you please explaine these lines for me?
//What to you mean by "for later usage"?
var btn_dlt = $(this); //assign the clicked button into a variable for later usage
//I didn't understand this part:
if(msg == "Success"){
/*using the clicked button to find the nearest parent with the class name to delete*/
btn_dlt.closest('.tr').remove();
Thank you.
lps 71 Posting Pro in Training
My 'later usage' is set because the ajax tempt to lose context, we need to save a reference to the object $(this)
by assigning it to a variable btn_dlt
so that when we wish to access this clicked button or its parent element, we can easily get it.
if(msg == "Success")
=> checking if the return from the ajax is same as the "Success" string.btn_dlt.closest('.tr')
=> if you check the html of the display from my code, you will probably found code similar to <tr class="tr"><td>1</td><td> <a href="single-post-page.php?post=1">test title</a> </td><td>lps</td><td> <a id="1" class="btn_dlt" href="#"> delete </a></td></tr><tr class="tr"><td>2</td><td> <a href="single-post-page.php?post=1">test title 2</a> </td><td>lps</td><td> <a id="2" class="btn_dlt" href="#"> delete </a></td></tr>
. This code will only find the nearest element with class 'tr' means that if you clicked on the id="2", it will find the <tr class="tr">
corresponding to you clicked element..remove()
=> remove the element
Niloofar24 15 Posting Whiz
Thank you @lps for explanation.
You forgot to answer my question about updating the page and html table at the time of clicking the Delete button.
lps 71 Posting Pro in Training
Can you show me your code? Because the script itself already include the part to remove the element: btn_dlt.closest('.tr').remove();
.
If you get a success message printed above the html table instead of the element being removed, what I think of maybe because your delete-action.php is not using echo "Success"; // the word here must be same as ajax comparism
, if you modified this text, please do modify for the same for if(msg == "Success")
.
For example: if my delete-action.php changed to echo "Post deleted";
then my script will have to be changed to if(msg == "Post deleted")
Edited by lps
Niloofar24 15 Posting Whiz
When i click delete button, the Success message appears above the html table but the html table doesn't update itself, i have to refresh the page to check the html table again and after refreshing the page, the post i have deleted is removed from there.
The delete-action.php file:
<?php
include('connection.php');
try {
$id=$_POST['id'];
$sql = "DELETE FROM Posts WHERE ID = '$id'";
$conn->exec($sql);
echo "Success"; // the word here must be same as ajax comparism
} catch(PDOException $e) {
echo "Query error:".$sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
<html>
<head>
<title>Delete-action</title>
</head>
</html>
And the script for admin page:
<?php
session_start();
// If the user is not logged in send him/her to the login form
if ($_SESSION["Login"] != "YES") {
header("Location: user-view-page.php");
}
include('connection.php');
try {
$sql = "SELECT ID, Title, Author, Content FROM Posts";
$result = $conn->query($sql);
echo "<h4>LOGGED IN AS: " . $_SESSION["Username"] . "</h4>";
echo "<p id='err_msg'></p>";//add this line for error message display, may add styling to this for bold and red color words
echo "<table cellspacing='0' cellpadding='20' border='1px solid black' border-collapse='collapse'>";
echo "<tr><th> POST ID </th><th> POST TITLE </th><th> POST AUTHOR </th><th> ACTION </th></tr>";
foreach($result as $row) {
echo "<tr class='tr'><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <a id='".$row['ID']."' class='btn_dlt' href='#'> delete </a> <br> <a href='edit-page.php?post=" . $row['ID'] . "'>Edit</a></td></tr>";
}
echo "</table>";
} catch(PDOException $e) {
echo "Query error:".$sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
<html>
<head>
<title>admin</title>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script><!--This is to include the jquery js for ajax to work, you can download it for better performance-->
<script>
//made sure the script only be bounded after all element being loaded
$(document).ready(function(){
$(".btn_dlt").click(function(){ // bind the function when the element with class btn_dlt is clicked
var btn_dlt = $(this); //assign the clicked button into a variable for later usage
$.ajax({
type: "POST",
url: "./delete-action.php", //post the data to delete-action.php
data: { id: btn_dlt.attr("id") } //set the id as data
}).done(function( msg ) { //when the ajax done(the return of the delete-action.php will be set into msg
if(msg == "Success"){
/*using the clicked button to find the nearest parent with the class name to delete*/
btn_dlt.closest('.tr').remove();
}else{
$('#err_msg').html(msg); //to write the message into err_msg field
}
});
});
});
</script>
<style>
a {
#text-decoration:none;
color:black;
}
h4 {
margin-left: 500px;
}
table {
background:#f3faf1;
}
</style>
</head>
<body>
<hr>
<?php
echo "<a href='writing-post.php'>Write new post</a><br><br>";
echo "<a href='user-view-page.php'>Log out</a>";
?>
</body>
</html>
As you see i have used almost the exact parts of code you gave me even with comments for now!
Edited by Niloofar24
lps 71 Posting Pro in Training
Please remove your code of
<html>
<head>
<title>Delete-action</title>
</head>
</html>
as this will made the ajax return not "Success"
but a 'Success<html><head><title>Delete-action</title></head></html>'
which result in the comparism if(msg == "Success")
failed and content being append to the $('#err_msg')
Niloofar24 15 Posting Whiz
I deleted that html part from delete-action.php file, but still when i click delete button, the message "Success" appears above the html table but the html table won't update itself.
lps 71 Posting Pro in Training
ok, so now have you checked the response from the ajax using developer tools from browser(F12)? If you wonder how to check, here is a print screen from my computer(I am using chrome).
F12->network, then click the button to trigger the ajax, my ajax request url is b.php, yours should saw the delete-action.php. Click on that and view the response tab. Is it totally the words "Success" only? or it havig other echo?
Niloofar24 15 Posting Whiz
Well F12->network, after that i clicked the button and 2 rows appears, the type of first row was html and for the second row was js. On the right column the request url was admin.php .
Click on that and view the response tab. Is it totally the words "Success" only? or it havig other echo?
There is a menu bove that right column which the request url was written there, on the menu the forth icon is Response. Is it the response tab you pointed to?
lps 71 Posting Pro in Training
Errrr.....Any print screen to show? Or you refer what I shown?
lps 71 Posting Pro in Training
My Request URL:http://localhost:4848/b.php is in General section under Headers tab. I think should be the things you mentioned.
Niloofar24 15 Posting Whiz
Or you refer what I shown?
Where did you show me?
My request url was http://www.my_domain_name/cms/admin.php
Is it ok or needed to get screenshot to show?
I still didn't understand where the problem backs to.
Edited by Niloofar24
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.