
has anyone tried Ajax in wordpress before coz it doesnt seem to be working for me..... i followed this tut. http://blog.parallax.lk/ajax-in-wordpress/ here is my code function register_my_theme_scripts() { wp_register_script( 'ajax_call_scripts', get_template_directory_uri() . '/assets/js/pages/ajax.js', array('jquery'), false, true ); wp_enqueue_script( 'ajax_call_scripts' ); wp_localize_script( 'ajax_call_scripts', 'ajax_params', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'postCommentNonce' => wp_create_nonce( 'ajax_params' ), 'action_call' => 'my_action', ) ); } // this hook is fired if the current viewer is not logged in & logged in do_action( 'wp_ajax_nopriv_my_action', 'theme_ajax_call'); do_action( 'wp_ajax_my_action', 'theme_ajax_call'); add_action( 'wp_enqueue_scripts', ' register_my_theme_scripts' ); function theme_ajax_call() { ob_clean(); echo 'here'; die(); } // the on ajax.js $.ajax({ type : "POST", url : ajax_params.ajaxurl, action : ajax_params.action_call, data : { 'postCommentNonce' : crimesmap_ajax.postCommentNonce, 'value' : $('#form_field').val().trim() }, success: function(ret) { console.log(ret); } });