<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Delete Row Animation WordPress Style In jQuery + Adding MySQL Delete</title>
	<atom:link href="http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/feed/" rel="self" type="application/rss+xml" />
	<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/</link>
	<description>Coding Tutorials, hints &#38; tips in PHP, jQuery, CSS &#38; HTML</description>
	<lastBuildDate>Thu, 29 Jul 2010 22:16:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Paul Robinson</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14101</link>
		<dc:creator>Paul Robinson</dc:creator>
		<pubDate>Mon, 08 Feb 2010 14:55:50 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14101</guid>
		<description>No problem, glad to help and Thank you. :)</description>
		<content:encoded><![CDATA[<p>No problem, glad to help and Thank you. <img src='http://return-true.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seborgarsen</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14099</link>
		<dc:creator>seborgarsen</dc:creator>
		<pubDate>Mon, 08 Feb 2010 14:34:41 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14099</guid>
		<description>Thank you so much, that did it! I&#039;ll make sure to send you another donation, imacs are cool and so are you.</description>
		<content:encoded><![CDATA[<p>Thank you so much, that did it! I&#8217;ll make sure to send you another donation, imacs are cool and so are you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Robinson</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14098</link>
		<dc:creator>Paul Robinson</dc:creator>
		<pubDate>Mon, 08 Feb 2010 14:15:42 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14098</guid>
		<description>Forgot to mention that without sending an action in the &lt;code&gt;$_POST&lt;/code&gt; array WP won&#039;t have a clue what PHP function to call, exactly the same as you form on your insert code.

So in this case you need to add an extra post value to your jQuery ajax call. The key would be &lt;code&gt;action&lt;/code&gt; and the value &lt;code&gt;playlist_data_delete&lt;/code&gt;.</description>
		<content:encoded><![CDATA[<p>Forgot to mention that without sending an action in the <code>$_POST</code> array WP won&#8217;t have a clue what PHP function to call, exactly the same as you form on your insert code.</p>
<p>So in this case you need to add an extra post value to your jQuery ajax call. The key would be <code>action</code> and the value <code>playlist_data_delete</code>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seborgarsen</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14096</link>
		<dc:creator>seborgarsen</dc:creator>
		<pubDate>Mon, 08 Feb 2010 13:19:51 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14096</guid>
		<description>I&#039;ve also tried

check_ajax_referer(&#039;something&#039;);
check_ajax_referer(&#039;something&#039;, &#039;wpsec&#039;);
check_ajax_referer(&#039;wpsec&#039;, &#039;something&#039;);
check_ajax_referer(&#039;wpsec&#039;);

all response 0 :(</description>
		<content:encoded><![CDATA[<p>I&#8217;ve also tried</p>
<p>check_ajax_referer(&#8216;something&#8217;);<br />
check_ajax_referer(&#8216;something&#8217;, &#8216;wpsec&#8217;);<br />
check_ajax_referer(&#8216;wpsec&#8217;, &#8216;something&#8217;);<br />
check_ajax_referer(&#8216;wpsec&#8217;);</p>
<p>all response 0 <img src='http://return-true.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seborgarsen</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14095</link>
		<dc:creator>seborgarsen</dc:creator>
		<pubDate>Mon, 08 Feb 2010 13:09:41 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14095</guid>
		<description>AAAH, yes. Obviously, just add what needs to be sent where it&#039;s being sent from! Thanks for getting in the fray :)

Now, only one slight thing,

[php] id: id, wpsec: &#039;&lt;?php wp_create_nonce(&#039;something&#039;); ?&gt;&#039; }[/php] doesn&#039;t return anything in wpsec:, so I made a function instead and echoed that, which works.

But I still get response 0 :/

As you, I can&#039;t see where we should get 0. Here&#039;s the code:

[php]add_action (&#039;wp_footer&#039;, &#039;delete_mpl_jquery&#039;);
function delete_mpl_jquery() { 

$noncense = wp_create_nonce(&#039;something&#039;); ?&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
jQuery(document).ready(function($){
	$(&#039;.box a&#039;).click(function() {
	id = $(this).parents(&#039;div.box&#039;).attr(&#039;id&#039;);
		id = id.replace(/delete-mpl-/, &quot;&quot;);
		el = $(this);
	jQuery.post(&#039;&lt;?php echo admin_url(&#039;admin-ajax.php&#039;); ?&gt;&#039;, { id: id, wpsec: &#039;&lt;?php echo $noncense; ?&gt;&#039;, ajax: &#039;true&#039; }, function(response) {
		//callback function here
	});
	return false;
});
});

&lt;/script&gt;
&lt;?php } ?&gt;

&lt;?php //this is the SQL and php for deleting playlists

add_action(&#039;wp_ajax_playlist_data_delete&#039;, &#039;playlist_delete&#039;);

function playlist_delete() {
	global $wpdb;
	$wpdb-&gt;show_errors();
	
	$piktud =  $_POST[&#039;id&#039;];
	
	check_ajax_referer(&#039;something&#039;, &#039;wpsec&#039;);
	
	$table_name = $wpdb-&gt;prefix . &quot;playlist_master&quot;;

	if(isset($_POST[&#039;ajax&#039;])) {
		if(isset($_POST[&#039;id&#039;])) {
  			$id = (int) $_POST[&#039;id&#039;];
			if($wpdb-&gt;query(&quot;DELETE FROM $table_name WHERE id = &quot;.$id)) {
				echo &#039;excellent&#039;;
				exit(1);
			}
		}
	}
die(69);
} ?&gt;[/php]</description>
		<content:encoded><![CDATA[<p>AAAH, yes. Obviously, just add what needs to be sent where it&#8217;s being sent from! Thanks for getting in the fray <img src='http://return-true.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now, only one slight thing,</p>
<pre class="brush: php;"> id: id, wpsec: '&lt;?php wp_create_nonce('something'); ?&gt;' }</pre>
<p> doesn&#8217;t return anything in wpsec:, so I made a function instead and echoed that, which works.</p>
<p>But I still get response 0 :/</p>
<p>As you, I can&#8217;t see where we should get 0. Here&#8217;s the code:</p>
<pre class="brush: php;">add_action ('wp_footer', 'delete_mpl_jquery');
function delete_mpl_jquery() { 

$noncense = wp_create_nonce('something'); ?&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
jQuery(document).ready(function($){
	$('.box a').click(function() {
	id = $(this).parents('div.box').attr('id');
		id = id.replace(/delete-mpl-/, &quot;&quot;);
		el = $(this);
	jQuery.post('&lt;?php echo admin_url('admin-ajax.php'); ?&gt;', { id: id, wpsec: '&lt;?php echo $noncense; ?&gt;', ajax: 'true' }, function(response) {
		//callback function here
	});
	return false;
});
});

&lt;/script&gt;
&lt;?php } ?&gt;

&lt;?php //this is the SQL and php for deleting playlists

add_action('wp_ajax_playlist_data_delete', 'playlist_delete');

function playlist_delete() {
	global $wpdb;
	$wpdb-&gt;show_errors();

	$piktud =  $_POST['id'];

	check_ajax_referer('something', 'wpsec');

	$table_name = $wpdb-&gt;prefix . &quot;playlist_master&quot;;

	if(isset($_POST['ajax'])) {
		if(isset($_POST['id'])) {
  			$id = (int) $_POST['id'];
			if($wpdb-&gt;query(&quot;DELETE FROM $table_name WHERE id = &quot;.$id)) {
				echo 'excellent';
				exit(1);
			}
		}
	}
die(69);
} ?&gt;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Robinson</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14094</link>
		<dc:creator>Paul Robinson</dc:creator>
		<pubDate>Mon, 08 Feb 2010 12:25:16 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14094</guid>
		<description>Ahhh ok if you don&#039;t have a form, it is a little different, but not by much. I&#039;m going to assume you are using a click event to make a text link trigger the delete command via AJAX.

To send across the extra data, in this case the nonce you could do this:
[js]
jQuery.(&#039;#delete-link&#039;).click(function() {
	jQuery.post(&#039;&lt;?php echo admin_url(&#039;admin-ajax.php&#039;); ?&gt;&#039;, { id: &#039;&lt;?php echo $id; ?&gt;&#039;, wpsec: &lt;?php wp_create_nonce(&#039;your-action-text&#039;); ?&gt;&#039; }, function(response) {
		//callback function here
	});
	return false;
});
[/js]
Something like that should do the trick. The &lt;code&gt;return false&lt;/code&gt; is just there to stop the href from submitting (if you used an href).

Hope that helps &amp; let me know how it goes. ;)</description>
		<content:encoded><![CDATA[<p>Ahhh ok if you don&#8217;t have a form, it is a little different, but not by much. I&#8217;m going to assume you are using a click event to make a text link trigger the delete command via AJAX.</p>
<p>To send across the extra data, in this case the nonce you could do this:</p>
<pre class="brush: jscript;">
jQuery.('#delete-link').click(function() {
	jQuery.post('&lt;?php echo admin_url('admin-ajax.php'); ?&gt;', { id: '&lt;?php echo $id; ?&gt;', wpsec: &lt;?php wp_create_nonce('your-action-text'); ?&gt;' }, function(response) {
		//callback function here
	});
	return false;
});
</pre>
<p>Something like that should do the trick. The <code>return false</code> is just there to stop the href from submitting (if you used an href).</p>
<p>Hope that helps &#038; let me know how it goes. <img src='http://return-true.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seborgarsen</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14091</link>
		<dc:creator>seborgarsen</dc:creator>
		<pubDate>Mon, 08 Feb 2010 11:53:22 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14091</guid>
		<description>I have to build a form instead, I can&#039;t get my head around wp_nonce_url makes no sense to my pea sized brain :)</description>
		<content:encoded><![CDATA[<p>I have to build a form instead, I can&#8217;t get my head around wp_nonce_url makes no sense to my pea sized brain <img src='http://return-true.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Robinson</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14026</link>
		<dc:creator>Paul Robinson</dc:creator>
		<pubDate>Fri, 05 Feb 2010 17:16:22 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14026</guid>
		<description>Well it&#039;s pretty much the same as your insert function. Send the nonce with your form using &lt;code&gt;wp_create_nonce();&lt;/code&gt; and then verify it in your delete function using &lt;code&gt;check_ajax_referer();&lt;/code&gt;.

I think a `brewski` is indeed in order. ;) If you noticed the site was down about 5-10 minutes ago I apologise, someone overloaded the server &amp; I had to get onto the admins to get it sorted. All done now though. :D</description>
		<content:encoded><![CDATA[<p>Well it&#8217;s pretty much the same as your insert function. Send the nonce with your form using <code>wp_create_nonce();</code> and then verify it in your delete function using <code>check_ajax_referer();</code>.</p>
<p>I think a `brewski` is indeed in order. <img src='http://return-true.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  If you noticed the site was down about 5-10 minutes ago I apologise, someone overloaded the server &#038; I had to get onto the admins to get it sorted. All done now though. <img src='http://return-true.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seborgarsen</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14025</link>
		<dc:creator>seborgarsen</dc:creator>
		<pubDate>Fri, 05 Feb 2010 16:44:31 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14025</guid>
		<description>nonce... that&#039;s a whole new can of worms opened for links.

I&#039;ve been staring at this all day, I&#039;m sure it&#039;s the solution. Now, I&#039;m just too bug eyed to figure thinks out. Methinks it&#039;s time for a brewski.</description>
		<content:encoded><![CDATA[<p>nonce&#8230; that&#8217;s a whole new can of worms opened for links.</p>
<p>I&#8217;ve been staring at this all day, I&#8217;m sure it&#8217;s the solution. Now, I&#8217;m just too bug eyed to figure thinks out. Methinks it&#8217;s time for a brewski.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Robinson</title>
		<link>http://return-true.com/2009/02/delete-row-animation-wordpress-style-in-jquery-adding-mysql-delete/comment-page-1/#comment-14024</link>
		<dc:creator>Paul Robinson</dc:creator>
		<pubDate>Fri, 05 Feb 2010 16:05:05 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=516#comment-14024</guid>
		<description>Ok. Not sure where that 0 is coming from as there is nothing in your code that seems to be able to produce that. 

Again though as this is function receiving data via AJAX I would add in a nonce &amp; verify it via &lt;code&gt;check_ajax_referer()&lt;/code&gt; before even attempting to delete a row so external requests can&#039;t trigger a deletion. 

I&#039;ve never made a AJAX call to &lt;code&gt;admin-ajax.php&lt;/code&gt; without providing a nonce so maybe it is refusing your AJAX request (returning 0) because no nonce is being verified. Although I&#039;m not sure about that.

Also just another little thing I noticed, you have wrote:
[php]
$id = $_POST[&#039;id&#039;];
//later in code
  if(isset($_POST[&#039;id&#039;])) {
[/php]
That is slightly backwards, you should probably use:
[php]
if(isset($_POST[&#039;id&#039;])) {
  $id = (int) $_POST[&#039;id&#039;];
[/php]
Hope that makes sense. ;)

I&#039;ll check a few more things out about why your code could be giving back 0, but let me know if you find anything else in the meantime. :)</description>
		<content:encoded><![CDATA[<p>Ok. Not sure where that 0 is coming from as there is nothing in your code that seems to be able to produce that. </p>
<p>Again though as this is function receiving data via AJAX I would add in a nonce &#038; verify it via <code>check_ajax_referer()</code> before even attempting to delete a row so external requests can&#8217;t trigger a deletion. </p>
<p>I&#8217;ve never made a AJAX call to <code>admin-ajax.php</code> without providing a nonce so maybe it is refusing your AJAX request (returning 0) because no nonce is being verified. Although I&#8217;m not sure about that.</p>
<p>Also just another little thing I noticed, you have wrote:</p>
<pre class="brush: php;">
$id = $_POST['id'];
//later in code
  if(isset($_POST['id'])) {
</pre>
<p>That is slightly backwards, you should probably use:</p>
<pre class="brush: php;">
if(isset($_POST['id'])) {
  $id = (int) $_POST['id'];
</pre>
<p>Hope that makes sense. <img src='http://return-true.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I&#8217;ll check a few more things out about why your code could be giving back 0, but let me know if you find anything else in the meantime. <img src='http://return-true.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
