// the on ajax.jshas anyone tried Ajax in wordpress before coz it doesnt seem to be working for me.....here is my code
i followed this tut. http://blog.parallax.lk/ajax-in-wordpress/
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();
}
$.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);
}
});
_______________________________________________
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke