- Author was Featured
- Has been a member for 4-5 years
- Author had a Free File of the Month
- Sold between 100 000 and 250 000 dollars
- Bought between 10 and 49 items
- Europe
- Exclusive Author
- Referred between 200 and 499 users
Hi everyone,
I am having trouble saving settings using ajax in my theme options page.
I am submitting the data using jQuery post with “action : theme_save_ajax” to Wordpress “ajaxurl” address.
then in the backend, I have added the following hook:
add_action(‘wp_ajax_theme_save_ajax, ‘theme_save’);
and the following function:
function theme_save() {
$this->options["name"] = $_POST["name"];
update_option('my_theme', $this->options);
die();
}
but I can’t even trigger the theme_save() function.
Using firebug, I can see that the jquery post is successful, returning “0”, not “-1”.
Hi Ant,
If the “theme_save” function is a sub-function of a class, it has to be called within the class when adding to “wp_ajax_” hook.
Ex: add_action( ‘wp_ajax_theme_save_ajax’, array(&$yourClass, ‘theme_save’) );
http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callbackRegards, Orkun
- Author was Featured
- Has been a member for 4-5 years
- Author had a Free File of the Month
- Sold between 100 000 and 250 000 dollars
- Bought between 10 and 49 items
- Europe
- Exclusive Author
- Referred between 200 and 499 users
Thanks Orkun, got it working!
You can add me on google chat if you are using:
anteksiler aaattttt gmail.com
