JQuery: setting radio button in group based on if
<p>This SHOULD be simple, I just know it should.</p>

<p>Basically, I have the code below in the error function of an $.ajax call. The call itself works. The call happens when the value of a radiobutton group goes from true to false or vice versa. If the error gets hit, I want to reset it to the previous value. What have I got wrong?</p>

<pre><code>if ($("input[name='enableEmail']:checked").val() == "true") {
                $("input[name='enableEmail'][value='false']").attr("checked", true);
            }
            else {
                $("input[name='enableEmail'][value='true']").attr("checked", true);                    
            }
</code></pre>

<p><strong>EDIT</strong> Apparently the question wasn't clear enough. I have two radio buttons in a group: On and Off. If user toggles from Off to On, a $.ajax call happens. If an error happens in the $.ajax call, I want to set the radio button back to Off. If the user toggles On to Off, I want it to go back to On in the event of an error</p>
