Use Jquery and PHP to delete a row from a table in HTML AND a Database simultaneously
I have am making a page using Ajax, Jquery, and PHP. I have gotten my table working so that when I click on a row it will set is as a 'selected' class, I have a button that says delete on it, but not sure how to link the two together.
My question is, how do I tell the button to get the id of the item in that row, send it to a pretty photo page and tell the database to delete it?
EDIT:
Here is some code:
// this is for the buttons
<
div id="controlPanelSpacer"></div>
<div id="controlPanel">
<div id="controlPanelContent">
<div class="btnContainer">
<a href="#editWindow">
<div id="cpEditButton" class="cpButton">
</div>
<span>Edit</span>
</a>
</div>
<div class="btnContainer">
<a href="#deleteWindow" rel="prettyPhoto">
<div id="cpDeleteButton" class="cpButton">
</div>
<span>Delete</span>
</a>
</div>
<a href="uploader.php" rel开发者_运维技巧="facebox">Upload</a>
</div>
</div>
</div>
//This is for the deleteWindow which I will be using PrettyPhoto
<div id="deleteWindow" style="display:none">
<div id="deleteWindow">
<form>
<p>
<label for="name">Name</label>
<p id="name" type="text">Are you sure you want to delete: </p>
</form>
</div>
</div>
When you click the button, you do an ajax call to your server that deletes it. Wait for a success reply from the server, then use jQuery to find the row and .remove()
it.
Create an ajax listener in PHP and make a request to that when you click the delete button, then just simply delete the local tags. (Ajax listener is just a normal PHP page called by a javascript (post/get) request)
精彩评论