Check if button was clicked in PHP from serialize() jquery
<p>I'm building a form to allow someone to change the color of buttons, to be used on a webpage, via a web GUI. It's set up to submit the changes via ajax, with jquery, for preview prior to the user clicking the save submit button so they can make sure they like the changes before saving them.</p>

<p>I understand that .serialize() will not send the value of a button click or even tell you that a button was clicked. I have googled and searched stackoverflow but I can't make any of the solutions work with my set up.</p>

<p><strong>How can the PHP script tell if the save button was clicked?</strong></p>

<p>HTML:</p>

<pre><code>&lt;div id="preview"&gt;&lt;/div&gt;

&lt;form id="build_form" class="build_form" action="button_preview.php" method="post"&gt;
    &lt;input name="color" type="radio" value="red" /&gt; red
    &lt;input name="color" type="radio" value="blue" /&gt; blue
    &lt;input name="save" type="submit" value="Save" class="button" /&gt;
&lt;/form&gt;
</code></pre>

<p>Javascript:</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function() {
    $(function() {
        $(".build_form").change(function() {
            $("form").submit();
        });
    });

    $('#build_form').submit(function() {
        $.ajax({
            data: $(this).serialize(),
            type: $(this).attr('method'),
            url: $(this).attr('action'), 
            success: function(response) {
                $('#preview').html(response);
            }
        });
        return false;
    });
});
&lt;/script&gt;
</code></pre>

<p>PHP:</p>

<pre><code>&lt;?php
    print_r($_POST);
?&gt;
</code></pre>
