Locale change on an ajax call

I get a different locale when I do an ajax call,

When I call this function on page load it gives me es_ES because my site is on the Spanish locale.

Read More
   function getCareerHtml(){
            global $locale;
            echo $locale.; //print es_ES
    }

When I call The above function using ajax it gives me the en_US locale.

       // js function
       function ajaxGetGlobalSerch(page){

    jQuery.ajax({

        url:POST http://localhost/mysite/wp-admin/admin-ajax.php",
        type:'POST',

        data:'action=ajaxGetCareerAction&page=',
        success:function(results)
        {
        alert("success");

        }
    });

}


   //function.php
   add_action('wp_ajax_ajaxGetCareerAction', 'getCareerHtml');
   add_action('wp_ajax_nopriv_ajaxGetCareerAction','getCareerHtml');
   function getCareerHtml(){
            global $locale;
            echo $locale.; //print en_US
                           // but it should print es_ES because site is set to spanish locale
    }

Related posts

Leave a Reply