Add Item and stay in current page - php, ajax, jquery - php

I am using google translator, so errors may occur.
My problem: add Item and stay in current page
I tried to use the advice from the link below but I did not succeed :-(
Add Item and stay in current page
Script code:
<?php
if( !defined( 'CUSTOMER_PAGE' ) )
exit;
require_once DIR_SKIN.'_header.php'; // include design of header
?>
<div id="product">
<?php
if( isset( $aData['sName'] ) ){ // displaying product content ?>
<script type="text/javascript">
var sTitle = "<?php echo $aData['sName']; ?>";
var fPrice = Math.abs( "<?php echo $aData['mPrice']; ?>" );
</script><?php
if( isset( $aData['mPrice'] ) || isset( $aData['sAvailable'] ) ){ // displaying box with price, basket and availability - START
echo '<div id="box">';
if( isset( $aData['mPrice'] ) && is_numeric( $aData['mPrice'] ) ){?>
<div id="price"><em><?php echo $lang['Price']; ?>:</em><strong id="priceValue"><?php echo $aData['sPrice']; ?></strong><span><?php echo $config['currency_symbol']; ?></span></div><?php
}
elseif( !empty( $aData['mPrice'] ) ){?>
<div id="noPrice"><?php echo $aData['sPrice']; ?></div><?php
}
if( isset( $aData['sAvailable'] ) ){?>
<div id="available"><?php echo $aData['sAvailable']; ?></div><?php
}
if( isset( $aData['mPrice'] ) && is_numeric( $aData['mPrice'] ) && !empty( $config['basket_page'] ) && isset( $oPage->aPages[$config['basket_page']] ) ){?>
<form action="<?php echo $oPage->aPages[$config['basket_page']]['sLinkName']; ?>" method="post" id="addBasket" class="form">
<fieldset>
<legend><?php echo $lang['Basket_add']; ?></legend>
<input type="hidden" name="iProductAdd" value="<?php echo $aData['iProduct']; ?>" />
<input type="hidden" name="iQuantity" value="1" />
<input type="submit" value="<?php echo $lang['Basket_add']; ?>" class="submit" />
</fieldset>
</form><?php
}
echo '</div>';
} // displaying box with price, basket and availability - END
}
?>
</div>
I've rewritten the code and added it below:
if( isset( $aData['sName'] ) ){ // displaying product content ?>
<script type="text/javascript">
$('#addBasket .submit').click(function() {
var keyValues = {
iProductAdd : $(this).parent().find('input[name="iProductAdd"]').val(),
iQuantity : $(this).parent().find('input[name="iQuantity"]').val()
};
$.post('<?php echo $oPage->aPages[$config['basket_page']]['sLinkName']; ?>', keyValues, function(rsp) {
// make your php script return some xml or json that gives the result
// rsp will be the response
});
return false; // so the page doesn't POST
});
</script>
But still does not work, after clicking the button, the product is added but we do not stay on the same page and go to the basket.
I will be grateful for any help
Adam

Can you try this ?
$('#addBasket .submit').click(function(event) {
event.preventDefault();
var keyValues = {
iProductAdd : $(this).parent().find('input[name="iProductAdd"]').val(),
iQuantity : $(this).parent().find('input[name="iQuantity"]').val()
};
$.post('<?php echo $oPage->aPages[$config['basket_page']]['sLinkName']; ?>', keyValues, function(rsp) {
// make your php script return some xml or json that gives the result
// rsp will be the response
});
return false; // so the page doesn't POST
});

You can use e.preventDefault() instead of return false;
<script type="text/javascript">
$('#addBasket .submit').click(function(e) {
e.preventDefault();
var keyValues = {
iProductAdd : $(this).parent().find('input[name="iProductAdd"]').val(),
iQuantity : $(this).parent().find('input[name="iQuantity"]').val()
};
$.post('<?php echo $oPage->aPages[$config['basket_page']]['sLinkName']; ?>', keyValues, function(rsp) {
// make your php script return some xml or json that gives the result
// rsp will be the response
});
});
Edit 1:
You can do one more thing. Instead of having input type as submit. keep it as button as I noticed you are making JSON manually.
So your input submit can be something like this
<input type="button" value="<?php echo $lang['Basket_add']; ?>" class="submit" />

The event listener is not being added to the button because the button doesn't exist when the script tag is above the form
Either put the script tag after the form or wrap the code in "ready" a call
$(function(){
$('#addBasket .submit').click(function() {
...
})

Related

Adding Wordpress "Add Media" Button to form in own Plugin

I am trying to add my own "Add Media" Button in my own plugin form pages, I created a plugin and I have a form in add-new.php file here is the code:
<div class="wrap">
<h1><?php _e( 'Add Deal', 'webdevs' ); ?></h1>
<form action="" method="post">
<!-- I NEED TO CHANGE THIS TO SHOW "ADD MEDIA BUTTON" -->
<input id="upload_image" type="text" size="36" name="upload_image" value="" />
<input id="upload_image_button" type="button" value="Upload Image" />
<?php wp_nonce_field( 'deal-new' ); ?>
<?php submit_button( __( 'Add Deal', 'webdevs' ), 'primary', 'submit_deal' ); ?>
</form>
How to add the html code and handle it in php
please help
Thnaks
I have created a custom image upload with metabox, you can set below code as per your need.
What you need is to call new WP's thickbox media uploader CSS and JS on your page. you have to modify condition of adding script for plugin page.
Condition to modify if( 'post' !== $typenow ).
What it will do?
It will allow you to open wordpress media uploader and send your selected image url to textbox then you can save the url in post_meta using update_post_meta() or wherever you want to save it. you can get the url from
Supposeable variable :
$content_img = $_POST['content_img'];
Html
<p>
<label><b>Upload Content Image</b></label><br/>
<input class="upload_image" name="content_img" type="text" readonly="readonly" value="<?php echo $content_img ?>"/>
<input type="button" value="Upload" class="button button-primary button-large" onclick="upload_new_img(this)"/>
Remove
</p>
Admin functions.php
// Enqueue script in admin
function my_admin_scripts() {
# Not our screen, bail out
if( 'post.php' !== $hook )
return;
# Not our post type, bail out
global $typenow;
if( 'post' !== $typenow )
return;
wp_enqueue_media('media-upload');
wp_enqueue_media('thickbox');
wp_register_script('my-upload', get_stylesheet_directory_uri().'/js/metabox.js', array('jquery','media-upload','thickbox'));
wp_enqueue_media('my-upload');
}
// Call thickbox CSS
function my_admin_styles() {
wp_enqueue_style('thickbox');
}
add_action('admin_enqueue_scripts', 'my_admin_scripts');
add_action('admin_enqueue_scripts', 'my_admin_styles');
Custom JS metabox.js
function upload_new_img(obj)
{
var file_frame;
var img_name = jQuery(obj).closest('p').find('.upload_image');
if ( file_frame ) {
file_frame.open();
return;
}
file_frame = wp.media.frames.file_frame = wp.media(
{
title: 'Select File',
button: {
text: jQuery( this ).data( 'uploader_button_text' )
},
multiple: false
}
);
file_frame.on('select', function() {
attachment = file_frame.state().get('selection').first().toJSON();
var newwurl = attachment.url.split('/wp-content');
img_name[0].value = '/wp-content'+newwurl[1];
file_frame.close();
// jQuery('.upload_image').val(attachment.url);
});
file_frame.open();
}
function remove_image(obj) {
var img_name;
if (jQuery(obj).closest('p').find('.upload_image').length > 0) {
img_name = jQuery(obj).closest('p').find('.upload_image');
} else {
img_name = jQuery(obj).closest('td').find('.upload_image');
}
if (typeof img_name != "undefined") {
img_name.val('');
}
}

Focusing On Empty Required Fields

Haloo, i have a problem here
Its my Validation Script
foreach ($product_options as $product_option) {
if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
$json['error']['product']['option'][$product_option['product_option_id']]
= sprintf($this->language->get('error_required'), $product_option['name']);
}
}
And its my Div Id
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
For now, that script just show up " fieldname is Required!"
i want it focus on the empty required field and show the "fieldname is Required!" text , Thank you
When you detect an error, output Javascript that sets focus on the invalid field.
foreach ($product_options as $product_option) {
if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
$json['error']['product']['option'][$product_option['product_option_id']]
= sprintf($this->language->get('error_required'), $product_option['name']);
?>
<script>
$(function () {
$("#option-<?php echo $product_option['product_option_id'] ?> input").focus();
});
</script>
<?php
}
}

Form when submitted to display a result (Firstname) on the thank you page

Stuck on a thing with PHP, i know it is something simple but am not sure of the correct way of doing it, either by jquery or php.
I have a contact form which when it submits its form, i want the results of some of the fields to display on the results thank you paeg saying:
Thank you for entering YOURNAME. Blah blah blah
Is this acheivable with a simple line of php or does it need to called through jquery.
Thanks, only new to php so somethings are still bit confusing
<?php
define('is_freetrial-celebrity', 1);
include_once('includes/header.inc.php');
?>
<div role="main" id="main">
<article id="mainFreetrial" class="greyBlock twoColumnsLayout">
<header>
<h1>Get Started</h1>
</header>
<div>
<form method="get" action="/forms_validation/freetrial.php" class="trialForm ajaxForm">
<div class="column">
<p>
<label for="firstNameTrial">First name<sup class="red">*</sup></label><input type="text" id="firstNameTrial" name="firstNameTrial" value="" required/>
</p>
<p>
<label for="lastNameTrial">Last name<sup class="red">*</sup></label><input type="text" id="lastNameTrial" name="lastNameTrial" value="" required/>
</p>
<p>
<label for="ageTrial">Age</label><input type="text" id="ageTrial" name="ageTrial" value=""/>
</p>
<p>
<label for="celebrityTrial" style="display: block; width: auto; margin-bottom: 5px;">Name the celebrity you would most like to meet, and why?<sup class="red">*</sup></label>
<textarea id="celebrityTrial" name="celebrityWhyTrial" style="width: 430px; height: 3em;" required></textarea>
</p>
<p class="ajaxFormBeforeValid">
<input type="submit" value="Submit now" class="redButton"/><span class="ajaxFormWait"></span><span class="ajaxFormError error"></span>
</p>
<div class="ajaxFormValid">
<p>
Thank you! Your local consultant will contact you soon. 'Like' us while you wait for all the latest VIP offers and promotions!
</p>
</div>
<p>
<small>
<sup class="red">*</sup>These are mandatory fields.
</small>
</p>
</div>
</form>
</div>
</article>
</div>
<?php include_once('includes/footer.inc.php'); ?>
Heres the jquery part
/*************************
plugin to manage ajax forms
*************************/
(function( $ ){
var methods = {
init : function( options ) {
return this.each(function(){
var $this = $(this),
data = $this.data('ajaxForm'),
ajaxForm = $('<div />', {
text : $this.attr('title')
});
// If the plugin hasn't been initialized yet
if ( ! data ) {
$(this).data('ajaxForm', {
target : $this,
ajaxForm : ajaxForm
});
//get the spinner, the valid box and the error box
var mySpinner = $this.find('.ajaxFormWait');
var myValid = $this.find('.ajaxFormValid');
var myError = $this.find('.ajaxFormError');
var myBeforeValid = $this.find('.ajaxFormBeforeValid');
myError.hide();
mySpinner.hide();
//add an event to send the form via AJAX
$this.submit(function(){
// get all the inputs into an array.
var $inputs = $this.find(':input:not([type="submit"], [type="button"])');
// not sure if you wanted this, but I thought I'd add it.
// get an associative array of just the values.
var values = {};
$inputs.each(function() {
if (this.type == "radio" || this.type == "checkbox"){
if($(this).is(':checked')){
if(typeof(values[this.name]) === 'undefined'){
values[this.name] = $(this).val();
}else{
values[this.name] += ', '+($(this).val());
}
}
} else
values[this.name] = $(this).val();
});
function defineTheInvalidsFields(fieldsList){
for(var i in fieldsList){
if(fieldsList[i] == 'closestStudio'){
$this.find('[name="'+fieldsList[i]+'"]').parent().addClass('invalid');
}else{
$this.find('[name="'+fieldsList[i]+'"]').addClass('invalid');
}
}
}
//send an AJAX request
$.ajax({
url: $this.attr('action'),
dataType: 'json',
data: values,
beforeSend: function(){
mySpinner.show();
},
success: function(result){
mySpinner.hide();
$this.find('.invalid').removeClass('invalid');
//error management
if(typeof(result.valid) === 'undefined'){
if(result.multipleSend){ //if multiple send
myError.html('Your request is already sent.');
}else if(result.required){ //if fields are required
defineTheInvalidsFields(result.required);
myError.html('The fields in red are required.');
}else if(result.format){ //if the forma is incorrect
defineTheInvalidsFields(result.format);
myError.html('The fields in red have invalid content.');
}else if(result.loginInvalid){
myError.html(result.loginInvalid);
}else{
myError.html('An unknown error occured.');
}
myValid.slideUp(300);
myError.slideDown(300);
}else if(typeof(result.loginUrl) !== 'undefined'){
window.location.href = result.loginUrl;
}else{
if(result.valid || result.valid == 'true'){
if($('#inputFreetrialFitnessFirst').length){
myBeforeValid.slideUp(300);
myError.slideUp(300);
myValid.slideDown(300);
}else{
window.location = '/free-trial-thank-you/';
}
}else{
myError.html('There was an error sending your details. Please try again.');
myValid.slideUp(300);
myError.slideDown(300);
}
}
}
});
return false;
});
//special case for the heardAbout
$('#heardAbout').change(function(){
if($(this).find('option:selected').attr('value') == 'Other'){
$('#otherHeardAbout').slideDown(300);
}else{
$('#otherHeardAbout').slideUp(300);
}
});
}
});
},
destroy : function(){
return this.each(function(){
var $this = $(this),
data = $this.data('ajaxForm');
// Namespacing FTW
$(window).unbind('.ajaxForm');
data.ajaxForm.remove();
$this.removeData('ajaxForm');
})
}
};
$.fn.ajaxForm = function( method ) {
// Method calling logic
if ( methods[method] ) {
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.ajaxForm' );
}
};
})( jQuery );
The form gets sent to the other page, is there a way to target a specific div and add the custom message with the name.
if(result.valid || result.valid == 'true'){
if($('#inputFreetrialFitnessFirst').length){
myBeforeValid.slideUp(300);
myError.slideUp(300);
myValid.slideDown(300);
}else{
window.location = '/free-trial-thank-you/';
}
}else{
myError.html('There was an error sending your details. Please try again.');
myValid.slideUp(300);
myError.slideDown(300);
}
if You wand to fetch specific element div via ajax call You can do like this:
$.ajax({
url: 'page.html',
success: function(data) {
item=$(data).filter('#specific_element');
$(selector).html(item);
}
});
If You wand to redirect to other page using
window.location = '/free-trial-thank-you/';
and then show data on a different page You should pass needet parameters like
window.location = '/free-trial-thank-you/page.php?name1=Daniel&name2=Pablo;
and on different site show parameters using _GET or _POST for example:
echo $_GET['name1'] or echo $_POST['name1'] if You use PSOT method in Your Ajax request
One way that I can think of is using session to store the information.
At freetrial.php store the form information in session like this:
session_start();
$_SESSION['firtNameTrial'] = $_GET['firstNameTrial'];
On ajax success, redirect the page to the thank you page using javascript windows.location.replace:
// similar behavior as an HTTP redirect
window.location.replace("http://yourwebpageaddress.com/thankyou.php");
Get the session on the thank you page. If you don't know, you may look at this example: Click here for session example

Deleting multiple rows from database by checkboxes

I want to delete multiple rows from database by checkboxes i have working script for "Check All" but when i want delete one or two , nothing happend.
JavaScript
<script type="text/javascript">
jQuery(function($) {
$("form input[id='check_all']").click(function() { // triggred check
var inputs = $("form input[type='checkbox']"); // get the checkbox
for(var i = 0; i < inputs.length; i++) { // count input tag in the form
var type = inputs[i].getAttribute("type"); // get the type attribute
if(type == "checkbox") {
if(this.checked) {
inputs[i].checked = true; // checked
} else {
inputs[i].checked = false; // unchecked
}
}
}
});
$("form input[id='submit']").click(function() { // triggred submit
var count_checked = $("[name='data[]']:checked").length; // count the checked
if(count_checked == 0) {
alert("Please select a comment(s) to delete.");
return false;
}
if(count_checked == 1) {
return confirm("Are you sure you want to delete these comment?");
} else {
return confirm("Are you sure you want to delete these comments?");
}
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('.submit').click(function(){
var checkValues = $('input[name=data[]]:checked').map(function()
{
return $(this).val();
}).get();
$.ajax({
url: 'resources/ajax/ajax_delete_comment.php',
type: 'post',
data: { data: checkValues },
success:function(data){
}
});
});
});
</script>
HTML/PHP
<form method="post" id="form">
Check All <input type="checkbox" id="check_all" value="">
Here im displaying record from database and <input name=\"data[]\" type=\"checkbox\" id=\"data\" value=" . $row['id'] . ">
<input name="submit" class="submit" type="submit" value="Delete" id="submit">
</form>
DELETING SCRIPT
if(isset($_POST['data'])) {
$id_array = $_POST['data']; // return array
$id_count = count($_POST['data']); // count array
for($i=0; $i < $id_count; $i++) {
$id = $id_array[$i];
$sql = $db->query("DELETE FROM comments WHERE `id` = '$id'");
if ($sql)
{
echo "success";
}
else
{
echo "Failed to delete the comment.";
}
}}
So its work for check all, but when im checking one or two objects, nothing happend, maybe someone could help?
Javascript
Since you are using jquery there is better way :)
<script type="text/javascript">
var is_activate = true; // we will track which input button was clicked :)
jQuery(function($) {
$("#form input#check_all").change(function() {
var inputs = $("#form input[type='checkbox']");
if ( $(this).is(":checked") ) {
inputs.prop( "checked", true );
// inputs.attr( "checked", true ); // if its not working
}
else {
inputs.removeAttr( "checked" );
}
});
// Track clicked button
$("#form input[type=submit]").on("click",function(e) {
is_activate = ( $(this).hasClass("activate_btn") ) ? true : false;
});
$("#form").submit(function(e) {
e.preventDefault();
var string = ( is_activate ) ? 'activate' : 'delete';
var data = $(this).serialize();
var checked = $(this).find("input[name='data[]']:checked").length;
if ( checked == 0 ) {
alert( "Please select a comment(s) to "+string+"." );
return false;
}
var text = "Are you sure you want to "+string+" these comment"+( ( checked == 1 ) ? "?" : "s?" );
if ( confirm( text ) ) {
$.ajax({
url: 'resources/ajax/'+( ( is_activate ) ? 'ajax_activate_comment.php' : 'ajax_delete_comment.php' ),
type: 'post',
data: data,
success: function( data ) {
}
});
}
});
});
</script>
HTML
<form method="post" id="form">
<label>Check All</label>
<input type="checkbox" id="check_all" value="">
<label>Here im displaying record from database and</label>
<input name="data[]" type="checkbox" id="data1" value="1">
<input name="data[]" type="checkbox" id="data2" value="2">
<!-- Activate Button -->
<input class="activate_btn" type="submit" name="activate" value="Activate" id="submit">
<!-- Delete Button -->
<input class="delete_btn" type="submit" name="delete" value="Delete" id="submit">
</form>
PHP
A single query is enough :)
<?php
if ( isset( $_POST['data'] ) ) {
$id_array = $_POST['data'];
if ( !empty( $id_array ) ) {
$id_array = implode( ",", $_POST['data'] ); // dont forget to sanitize
$sql = $db->query( "DELETE FROM comments WHERE `id` IN (".$id_array.")" );
}
}
?>
And remember, its not good that doing this all in client side.
You can do POST request to a single file, since your each input button has a unique name.
So in your PHP code, you can find which button was clicked like this.
<?php
if ( isset( $_POST["activate"] ) ) {
$sql = $db->query( "UPDATE comments SET status = '1' WHERE `id` IN (".$id_array.")" );
}
else {
$sql = $db->query( "DELETE FROM comments WHERE `id` IN (".$id_array.")" );
}
?>
look how simple :) Isn't it?

PHP/jQuery: Ajax call & where to have my code?

So im making a "delete" button to my commentsystem..
I want to make it smart, so it should run a ajax call to remove the comment.
Now I have tried out myself, this and have gotten this far:
<?php
echo "<a href='#' onclick='javascript:DoCommentWallRemove()' title='ta bort inlägg'> <span class='removeWallComment'></span> </a>";
?>
<script type="text/javascript">
function DoCommentWallRemove(){
var wrapperId = '#profileWall';
$.ajax({
type: "POST",
url: "misc/removeWallComment.php",
data: {
value: 'y',
commentwallid : "<?php echo $displayWall['id']; ?>",
BuID : "<?php echo $v['id']; ?>",
uID : "<?php echo $showU['id']; ?>"
},
success: function(msg){
alert(msg);
}
});
}
</script>
Now as my comments shows in a while(), I have placed the JS function is right under the link, so it should grab the actual comment id, but instead it gives the same ID to every comment.
But when i do a normal php <?php echo $displayWall['id']; ?> it shows different comment ids like it should do in the javascript.
I would suggest a similar solution to GuidoH, but with a few minor changes.
PHP Code for the Comment Thread:
<form method="post" action="misc/removeWallComment.php">
<input type="hidden" name="value" value="y" />
<input type="hidden" name="BuID" value="<?php echo $v['id']; ?>" />
<input type="hidden" name="uID" value="<?php echo $showU['id']; ?>" />
<div id="commentList">
<?php
foreach( $comments as $c ){
echo '<div id="comment'.$c['id'].'">';
echo $c['commentBody'];
echo '<input class="delButton" type="submit" name="'.$c['id'].'" value="Delete Comment" />';
echo '</div>';
}
?>
</div>
</form>
This will render as:
<form method="post" action="misc/removeWallComment.php">
<input type="hidden" name="value" value="y" />
<input type="hidden" name="BuID" value="ThisIsThe_BuID" />
<input type="hidden" name="uID" value="ThisIsThe_uID" />
<div id="commentList">
<div id="comment001">
This is Comment Number One
<input class="delButton" type="submit" name="001" value="Delete Comment" />
</div>
<div id="comment002">
And, This is Comment Number Two
<input class="delButton" type="submit" name="002" value="Delete Comment" />
</div>
</div>
</form>
In the Javascript for the page holding the Comment thread:
<script>
$(document).ready(function(){
/* Add a Handler for the Delete Button */
$('div#commentList input.delButton').click(function(e){
/* Stop the Link working */
e.preventDefault();
/* Alias the main jQuery Objects */
$this = $(this);
$comment = $this.closest('div');
$form = $comment.closest('form');
/* Grab the Comment Number from the Button's NAME attribute */
commentID = $this.attr('name');
/* Perform the AJAX Action */
$.ajax({
url : $form.attr('action') ,
type : 'POST' ,
data : {
'value' : $form.find( 'input[name="value"]' ).val() ,
'commentwallid' : commentID ,
'BuID' : $form.find( 'input[name="BuID"]' ).val() ,
'uID' : $form.find( 'input[name="uID"]' ).val() ,
'mode' : 'ajax'
} ,
dataType : 'text' ,
complete: function( XHR , status ){
if( $.trim(status).toLowerCase()=='success'
&& $.trim(XHR.responseText).toLowerCase()=='comment deleted' ){
/* Success - Hide, then Remove the Comment */
$comment.hide().remove();
}else{
/* Something Went Wrong */
alert('Deleting Comment #'+commentID+' Failed');
}
}
});
});
});
</script>
In the misc/removeWallComment.php file:
if( $_POST['mode']=='ajax' ){
/* Perform the Action. Return 'Comment Deleted' is Successful */
}else{
/* This is to Extract the Comment ID from the "Delete Comment" button */
$_POST_REV = array_flip( $_POST );
$_POST['commentwallid'] = $_POST_REV['Delete Comment'];
/* Perform the Action.
Return the Full Page, or Redirect, you want Non-Javascript Users to See. */
}
NOTE:
This advice is based on the assumption he BuID and uID variables are the same for any delete action performed by the user from the same page.
Edited:
Updated to provide Graceful Degradation in the event that the user does not allow Javascript to run, and to extract a number of variables from the HTML FORM, (rather than have to code them in twice).
Eww, that's just gross! You probably want something like this:
function removeComment(id, obj) {
$.post('misc/removeWallComment.php', {id: id}, function(msg) {
alert(msg); // or do some useful stuff,
// like remove the comment from the page
// with 'obj' you'll know which comment to remove :)
});
}
And then just something like this for each comment:
delete comment

Categories