Title: decree's Replies | WordPress.org

---

# decree

  [  ](https://wordpress.org/support/users/decree/)

 *   [Profile](https://wordpress.org/support/users/decree/)
 *   [Topics Started](https://wordpress.org/support/users/decree/topics/)
 *   [Replies Created](https://wordpress.org/support/users/decree/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/decree/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/decree/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/decree/engagements/)
 *   [Favorites](https://wordpress.org/support/users/decree/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [refresh php function with jquery](https://wordpress.org/support/topic/refresh-php-function-with-jquery/)
 *  Thread Starter [decree](https://wordpress.org/support/users/decree/)
 * (@decree)
 * [7 years ago](https://wordpress.org/support/topic/refresh-php-function-with-jquery/#post-11537289)
 * hey guys
    i ask question a few days ago about refresh php function with jquery
   and my dear friend joy said : use wordpress ajax interface i solved my problem
   and share it : ::::::::::::: my js code :::::::::::::
 *     ```
       jQuery(document).ready(function($) {
       	var data = {
       		'action': 'refresh_message'     // We pass php values differently!
       	};
       	// We can also pass the url value separately from ajaxurl for front end AJAX implementations
       	function refreshmessage() {
   
       		jQuery.post(refresh_object.php_ajax, data, function(response) {
       			$("#circlemessageshow-refresh").html(response);
       		});
       	}
   
       setInterval(refreshmessage,000);
       });
   
       <a href="https://codex.wordpress.org/AJAX_in_Plugins" rel="noopener" target="_blank">source</a>
       ```
   
 * ::::::::::::: my php code :::::::::::::
 *     ```
       function add_refreshjquery() {
         wp_register_script( 'refresh-js', get_template_directory_uri(). '/js/refresh.js', array('jquery'), '1.0.0', true );
         wp_localize_script( 'refresh-js','refresh_object',array(
           'php_ajax' => admin_url( 'admin-ajax.php' ),
         ));
         wp_enqueue_script('refresh-js');
       }
       add_action('wp_enqueue_scripts', 'add_refreshjquery');
   
       add_action( 'wp_ajax_refresh_message', 'my_action' );
       function my_action() {
       	global $wpdb;
         $mymessage  = $wpdb->get_results("SELECT option_value FROM wp_options WHERE option_id = 142");
         foreach($mymessage as $page){
           $circlemessageshowbox = $page->option_value;
           echo $circlemessageshowbox;
         }
         wp_die();
       }
       ```
   
 * [source](https://codex.wordpress.org/AJAX_in_Plugins)
    -  This reply was modified 7 years ago by [decree](https://wordpress.org/support/users/decree/).
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [refresh php function with jquery](https://wordpress.org/support/topic/refresh-php-function-with-jquery/)
 *  Thread Starter [decree](https://wordpress.org/support/users/decree/)
 * (@decree)
 * [7 years ago](https://wordpress.org/support/topic/refresh-php-function-with-jquery/#post-11523158)
 * dear joy
    thank you for answer and for showing way to resolve this problem

Viewing 2 replies - 1 through 2 (of 2 total)