<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NinjaCipher &#187; js</title>
	<atom:link href="http://www.ninjacipher.com/tag/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ninjacipher.com</link>
	<description>kungpow programming</description>
	<lastBuildDate>Thu, 25 Mar 2010 14:39:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='www.ninjacipher.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>post_from_link javascript tip</title>
		<link>http://www.ninjacipher.com/2008/12/13/post_from_link-javascript-tip/</link>
		<comments>http://www.ninjacipher.com/2008/12/13/post_from_link-javascript-tip/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 23:50:03 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=55</guid>
		<description><![CDATA[I wrote this the other day. Thought someone might find it useful. Will let you do a POST request from a link. Good for delete buttons, since we all know your not supposed to let users delete things from a get request&#8230; right?!   
Basically it takes your url &#038; params and dynamically builds [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this the other day. Thought someone might find it useful. Will let you do a POST request from a link. Good for delete buttons, since we all know your not supposed to let users delete things from a get request&#8230; right?! <img src='http://www.ninjacipher.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<p>Basically it takes your url &#038; params and dynamically builds the DOM for the form and then submits it. </p>
<p>Requires that you include <a href="http://www.prototypejs.org" target="prototype">prototype.js</a>.</p>
<p>Here is an example link. You just pass the url you wish to submit to and an associative array of the params.</p>
<pre name="code" class="html"><a href="#" onClick="post_from_link('/the/url/to/post/to',{'param1':'val1','param2':'val2'});" >post the request</a></pre>
<p>Here is the js function. Include this in the head of your page.</p>
<pre name="code" class="javascript">
/*
* Dynamically creates a form based on args and submits it to the given url
* @param {Object} url
* @param {Object} params
*/
function post_from_link(url,params){
   var form = new Element('form', { action: url, method: 'POST' });
   for(param in params){
       var hidden = new Element('input', {type:'hidden', name:param, value:params[param]});
       form.insert(hidden);
   }
   document.body.appendChild(form);
   form.submit();
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/12/13/post_from_link-javascript-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
