Use transposh in Ajax event
-
Hello
I cannot get transposh to translate data retrieve from ajax. The ajax works well but the content is not translate.
Can you help me? What i am missing?Here is my example with accessing the page in french for example
The transposh.php on_init()
if (isset($_GET[‘action’]) && $_GET[‘action’] == ‘essairor’) {
$this->target_language = transposh_utils::get_language_from_url($_SERVER[‘HTTP_REFERER’], $this->home_url);
$this->attempt_json = true;
}the html
<button id=”ess”>ee</button>The javascript
jQuery(document).ready(function($) {
$(‘#ess’).on(‘click’,function(e) {
e.preventDefault();
jQuery.ajax({
url :ajaxurl,
data: {
‘action’:’essairor’
},
success: function( data ) {
alert( data);
}
)};
)};The server side php
add_action( ‘wp_ajax_essairor’, ‘essairor’ );
add_action(‘wp_ajax_nopriv_essairor’, ‘essairor’);
function essairor() {
echo json_encode(“good bye”);
}
- The topic ‘Use transposh in Ajax event’ is closed to new replies.