
That was the best caption for the situation. Thanks On Mon, Nov 11, 2013 at 8:54 AM, Derrick Wesonga <wesongaderrick@gmail.com>wrote:
[image: Inline image 1]
On Fri, Nov 8, 2013 at 10:50 PM, Ken Muturi <muturiken@gmail.com> wrote:
@ derrick,
I have done ajax on php before, i am using the approach above because of i want to call a method (theme_ajax_call) in functions.php in wordpress. The above method is what has been defined in the wordpress ref .. http://codex.wordpress.org/AJAX_in_Plugins
The above had been returning a 0 instead of the response - 'here', It just started working from no where after several hours of debugging.
Thanks.
On Fri, Nov 8, 2013 at 5:08 PM, Derrick Wesonga <wesongaderrick@gmail.com
wrote:
Have you worked with ajax on two plain php pages? Its pretty much the same way, jquery made it simple. create page one. create page two the same way you create other wordpress "pages". Include jquery on page one header.php call page two and pass parameters (refer to this http://api.jquery.com/jQuery.ajax/) decide what to do with the data you are getting I can see right now you are sending it to browser console.
Also you can use the console to debug your javascript code regards
On Thu, Nov 7, 2013 at 5:25 PM, Ken Muturi <muturiken@gmail.com> wrote:
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); } });
_______________________________________________ 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
_______________________________________________ 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
_______________________________________________ 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
_______________________________________________ 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