Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function cfgeo_settings_javascript() { ?>
- <script type="text/javascript" >
- (function($){
- $(document).ready(function(){
- $("input[id^='cf_geo_'], select[id^='cf_geo_'], textarea[id^='cf_geo_']").on("change keyup", function(){
- var This = $(this),
- name = This.attr("name"),
- value = This.val(),
- data = {};
- data['action'] = 'cfgeo_settings';
- data[name] = value;
- console.log(data);
- console.log(ajaxurl);
- $.post(ajaxurl, data).done(function(returns){
- console.log(returns);
- });
- });
- });
- }(window.jQuery));
- </script> <?php
- }
- add_action( 'admin_footer', 'cfgeo_settings_javascript');
- function cfgeo_settings_callback() {
- global $wpdb; // this is how you get access to the database
- var_dump($_POST);
- if (isset($_POST)) {
- // Do the saving
- $front_page_elements = array();
- $updates=array();
- foreach($_POST as $key=>$val){
- if($key != 'cfgeo_settings')
- update_option($key, esc_attr($val));
- }
- echo 'true';
- }
- else
- echo 'false';
- wp_die(); // this is required to terminate immediately and return a proper response
- }
- add_action( 'wp_ajax_cfgeo_settings', 'cfgeo_settings_callback');
- ?>
- Object {action: "cfgeo_settings", cf_geo_enable_ssl: "true"}
- admin.php?page=cf-geoplugin-settings:1733 /wp-admin/admin-ajax.php
- admin.php?page=cf-geoplugin-settings:1736 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement