• Resolved hcsweb

    (@hcsweb)


    Hello,
    we used to load the GTranslate Shortcode by click (for reasons of data protection). Recently it stopped loading. Do you havy any idea, what could be the reason why?

    This is the button used in our theme:

    <button id="trigger_translation">Google Translate aktivieren</button>

    This is in the functions.php
    (When I insert a shortcode from another plugin there, it works)

    // Translation on click
    function runTranslation() {
      if ( isset($_REQUEST) ) {
        echo do_shortcode( '[gtranslate]' );
      }
      die();
    }
    add_action( 'wp_ajax_runTranslation', 'runTranslation' );
    add_action( 'wp_ajax_nopriv_runTranslation', 'runTranslation' );

    This is the javascript code:

    // load translation
    	$('#trigger_translation').click(function(e) {
    		e.preventDefault();
    
    		$.ajax({
    		  url: '/wp-admin/admin-ajax.php',
    		  type: 'GET',
    		  data: {
    			'action' : 'runTranslation',
    		  },
    		  success:function(data) {
    			  $('#translation').html(data);
    		  }
    		});
    	});
    	
    });
    • This topic was modified 1 year, 12 months ago by hcsweb.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Load GTranslate on click’ is closed to new replies.