Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Wordpress Ajax callback action
- add_action('wp_ajax_chat_comms', 'chat_comms');
- function chat_comms(){
- //no nounce for the moment, just test data is being received ok....
- $message= $_POST['txt'];
- if($message){
- echo $message;
- } else {
- echo 'the function is called correctly so we know ajax url and the action parameter is ok, sadly we have miss spelled the post variable or have a issue with our ajax method..';
- }
- exit; // no trailing 0's
- }
- // lets load a new js file to rule out caching issues....
- function load_chat_me_styles(){
- $pldir=get_site_url().'/wp-content/plugins/chat_me/';
- wp_enqueue_style( 'chat_me-style', $pldir.'css/chat_me.css' );
- wp_enqueue_script('chat_me-script', $pldir.'js/newchat_me.js', array('jquery') ); // --> note file name for js file + lets be sure we wait for jquery to be loaded....
- wp_localize_script( 'chat_me-script', 'chat_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ))); .. not being used in the script --> if ajaxurl is undefined replace with chat_ajax.ajaxurl
- }
- add_action( 'admin_enqueue_scripts', 'load_chat_me_styles' ); //-->note changed hook!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement