<?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"
	>
<channel>
	<title>Comments on: Abstracting JavaScript and AJAX requests in PHP (and even building valid HTML)</title>
	<atom:link href="http://blog.octabox.com/2007/07/20/abstracting-javascript-and-ajax-requests-in-php-and-even-building-valid-html/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.octabox.com/2007/07/20/abstracting-javascript-and-ajax-requests-in-php-and-even-building-valid-html/</link>
	<description>Opinions on starting up online, web development, graphical design and other random curiosities</description>
	<pubDate>Thu, 21 Aug 2008 20:03:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Eran Galperin</title>
		<link>http://blog.octabox.com/2007/07/20/abstracting-javascript-and-ajax-requests-in-php-and-even-building-valid-html/#comment-418</link>
		<dc:creator>Eran Galperin</dc:creator>
		<pubDate>Sat, 26 Apr 2008 18:15:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.octabox.com/2007/07/20/abstracting-javascript-and-ajax-requests-in-php-and-even-building-valid-html/#comment-418</guid>
		<description>In my opinion use a form for both cases (javascript on or off), with hidden inputs for the rest of the variables.
Attach a submit event to the form via javascript (if you are using jQuery, read &lt;a href="http://docs.jquery.com/Events/submit" rel="nofollow"&gt;this&lt;/a&gt;), and inside the event callback prevent the regular submit event from happening using the preventDefault() method. ie:

&lt;code&gt;
$('form#myform').submit(function(event){
        //Prevent the regular submit event
        event.preventDefault();
        //Serialize all the form variables
        var params = $(form).serialize();
       .... do stuff with variables, like sending them via ajax ...
});
&lt;/code&gt;

If javascript is disabled on the client, the event will not be attached, and the form will be submitted like a regular form. Hope this helps</description>
		<content:encoded><![CDATA[<p>In my opinion use a form for both cases (javascript on or off), with hidden inputs for the rest of the variables.<br />
Attach a submit event to the form via javascript (if you are using jQuery, read <a href="http://docs.jquery.com/Events/submit" rel="nofollow" onclick="javascript:pageTracker._trackPageview('/outbound/comment/docs.jquery.com');">this</a>), and inside the event callback prevent the regular submit event from happening using the preventDefault() method. ie:</p>
<p><code><br />
$('form#myform').submit(function(event){<br />
        //Prevent the regular submit event<br />
        event.preventDefault();<br />
        //Serialize all the form variables<br />
        var params = $(form).serialize();<br />
       .... do stuff with variables, like sending them via ajax ...<br />
});<br />
</code></p>
<p>If javascript is disabled on the client, the event will not be attached, and the form will be submitted like a regular form. Hope this helps</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Herve</title>
		<link>http://blog.octabox.com/2007/07/20/abstracting-javascript-and-ajax-requests-in-php-and-even-building-valid-html/#comment-417</link>
		<dc:creator>Herve</dc:creator>
		<pubDate>Sat, 26 Apr 2008 11:55:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.octabox.com/2007/07/20/abstracting-javascript-and-ajax-requests-in-php-and-even-building-valid-html/#comment-417</guid>
		<description>Thanks for this article, 
I am looking for a solution to write Ajax code that can be switched off if Javascript is not enabled on the client. 

Therefore, onclick, onmouser and so on should integrate the button only when Javascript is enabled, otherwise, the button would be a normal submit.

I believe the solution lies in handling the form with either hidden fields and submit button when javascript is disabled. Otherwise, no form, no hidden fields are populated. Instead, the query string to process through ajax is built using the same variables.

I am more than eager to have your feedback on this</description>
		<content:encoded><![CDATA[<p>Thanks for this article,<br />
I am looking for a solution to write Ajax code that can be switched off if Javascript is not enabled on the client. </p>
<p>Therefore, onclick, onmouser and so on should integrate the button only when Javascript is enabled, otherwise, the button would be a normal submit.</p>
<p>I believe the solution lies in handling the form with either hidden fields and submit button when javascript is disabled. Otherwise, no form, no hidden fields are populated. Instead, the query string to process through ajax is built using the same variables.</p>
<p>I am more than eager to have your feedback on this</p>
]]></content:encoded>
	</item>
</channel>
</rss>
