Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have my own plugin options page, but when users hit "Save" button the whole page refreshes.

Is there a way of changing my script below to something that will for example popup yellow box saying "settings saved" WITHOUT page refresh? So the data will be passed trough ajax call or something like that.

I've seen something like that before, but can't recall for what plugin.

add_action('admin_menu', 'my_plugin_menu');

function my_plugin_menu() {

    add_menu_page('My Plugin Options', 'Plugin Options', 'manage_options', 'my-unique-identifier', 'my_plugin_options'); 

}

function my_plugin_options() {

  if (!current_user_can('manage_options'))  {
    wp_die( __('You do not have sufficient permissions to access this page.') );
  } ?>

<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>
(...)
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="option1,option2,option3,etc." />
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</form>
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Using AJAX In Your WordPress Theme Admin looks like it is kind of what you are talking about.

share|improve this answer
    
I'm gonna check that within the next few days! I hope it works. Thank you! –  Wordpressor Feb 24 '11 at 22:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.