<?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>Kolodvor &#187; jQuery</title>
	<atom:link href="http://www.kolodvor.net/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kolodvor.net</link>
	<description>ruby, rails, javascript, jquery, ...</description>
	<lastBuildDate>Mon, 16 Jan 2012 15:24:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Rails, CSRF and Ajax requests</title>
		<link>http://www.kolodvor.net/2010/01/02/rails-csrf-and-ajax-requests/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rails-csrf-and-ajax-requests</link>
		<comments>http://www.kolodvor.net/2010/01/02/rails-csrf-and-ajax-requests/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 00:36:03 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
				<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[csrf]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[forgery]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[protection]]></category>
		<category><![CDATA[token]]></category>

		<guid isPermaLink="false">http://kolodvor.net/?p=64</guid>
		<description><![CDATA[Rails protects controller actions from CSRF (Cross-Site Request Forgery) attacks with a token based on a random string stored in the session. The token parameter is named authenticity_token by default and will be embedded in all forms and Ajax requests &#8230; <a href="http://www.kolodvor.net/2010/01/02/rails-csrf-and-ajax-requests/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Rails protects controller actions from <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">CSRF</a> (Cross-Site Request Forgery) attacks with a token based on a random string stored in the session. The token parameter is named <code>authenticity_token</code> by default and will be embedded  in all forms and Ajax requests generated by Rails.</p>
<p>You should also add this token to all Ajax request that you hand coded. As suggested in <a href="http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#M000514">Rails documentation</a> you can add this line in <code>head</code> section.</p>
<pre class="code">
  &lt;%= javascript_tag "window._token = '#{form_authenticity_token}'" %&gt;;
</pre>
<p>and then add authenticity_token to parameters option of Ajax requests</p>
<pre class="code">
  new Ajax.Request('/some/url', {
    parameters: "foo=bar&#038;authenticity_token="+_token
  });
</pre>
<h3>Remote forgery protection plugin</h3>
<p>This can get tedious if you have a lot of Ajax requests so I wrote a simple <a href="http://github.com/vlado/remote_forgery_protection">plugin</a> that adds authenticity token to all Ajax requests automatically.</p>
<p>You can install it with</p>
<pre class="code">
  script/plugin install git://github.com/vlado/remote_forgery_protection.git
</pre>
<p>Now all you have to do is add this line inside <code>head</code> section of you&#8217;re layout</p>
<pre class="code">
  &lt;%= remote_forgery_protection %&gt;
</pre>
<p>and all non GET Ajax request will have authenticity_token parameter automatically included.</p>
<p><span id="more-64"></span></p>
<p><span style="text-decoration:line-through">Magic is done by wrapping Ajax.Base using <a href="http://api.prototypejs.org/language/function.html#wrap-instance_method">Function#wrap</a> method so this will work only if you are using <a href="http://prototypejs.org">Prototype</a>.<br />
I plan to add support for other libraries (if there is interest) in the future so keep in touch.</span></p>
<p>Remote forgery protection currently supports <a href="http://www.prototypejs.org">Prototype</a>, <a href="http://www.jquery.com">jQuery</a> and <a href="http://www.extjs.com">ExtJS</a>. Let me know if you would like to see it working with some other library</p>
<p>Plugin page: <a href="http://github.com/vlado/remote_forgery_protection">http://github.com/vlado/remote_forgery_protection</a></p>
<p>More info:<br />
<a href="http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html">api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html</a><br />
<a href="http://isc.sans.org/diary.html?storyid=1750">isc.sans.org/diary.html?storyid=1750</a><br />
<a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">en.wikipedia.org/wiki/Cross-site_request_forgery</a><br />
<a href="http://opensoul.org/2008/10/24/ajax-and-request-forgery-protection">opensoul.org/2008/10/24/ajax-and-request-forgery-protection</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kolodvor.net/2010/01/02/rails-csrf-and-ajax-requests/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Set focus on first field with jQuery</title>
		<link>http://www.kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=set-focus-on-first-field-with-jquery</link>
		<comments>http://www.kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 17:50:41 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[focus]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[selectors]]></category>

		<guid isPermaLink="false">http://kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/</guid>
		<description><![CDATA[f you are using Prototype see this post. Setting focus on the first text field with jQuery is as simple as $("input:text:first").focus(); $("input:text:visible:first").focus(); Find more at http://docs.jquery.com/Selectors Update: If you are on Rails you can use auto_focusable_forms, dependency free plugin &#8230; <a href="http://www.kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>f you are using <a href="http://www.prototype.org">Prototype</a> see <a href="http://kolodvor.net/2010/01/02/set-focus-on-first-field-with-prototype">this</a> post.</p>
<p>Setting focus on the first text field with <a href="http://www.jquery.com">jQuery</a> is as simple as</p>
<pre class="code">
  <span style="text-decoration:line-through">$("input:text:first").focus();</span>
  $("input:text:visible:first").focus();
</pre>
<p>Find more at <a href="http://docs.jquery.com/Selectors">http://docs.jquery.com/Selectors</a></p>
<p><strong>Update</strong>: If you are on <a href="http://rubyonrails.org">Rails</a> you can use <a href="http://github.com/dcadenas/auto_focusable_forms/tree/master">auto_focusable_forms</a>, dependency free plugin that will focus first input for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

