title: Saving wordpress settings api options with ajax,
body: <p>I have been wrestling with this problem for quite some time now. 
  I have an options page for a theme, and a single option registered. </p>
  
  <p>I have been trying to get the option updated via ajax every time a user presses the save button, here is my code. </p>
  
  <p>JS:</p>
  
  <pre><code>       function save_main_options_ajax() {
  
          $('.main-options-form').submit( function () { 
  
              var b       =  $(this).serialize(),
                  optdata =  { action : "wp_ajax_main_options_save", data: b };
  
              $.post( ajaxurl, b, function (response) {
                  if (response == 1 ) { alert('sucess'); }
                  else { alert(optdata);}
              });
              return false;               
          });
      }
  save_main_options_ajax();
  </code></pre>
  
  <p>The php:</p>
  
  <pre><code> function main_options_save_ajax() { 
  
          check_ajax_referer('_wpnonce', '_wpnonce' );
  
          $data = $_POST;
          unset($data['option_page'], $data['action'], $data['_wpnonce'], $data['_wp_http_referer']);
  
  
          if ( update_option('main_options', $data ) )
          { die(1); }
          else { die (0); }           
  }
  add_action('wp_ajax_main_options_save', 'main_options_save_ajax' );
  </code></pre>
  
  <p>The response i see in firebug is 0. Im not sure what im missing here, i have tried this with some variations but nothing seems to work. </p>