I have a php function that simply get me the value of an array given the key.
Example:
<?=__('mykey')?>
Return the value of my array.
I would to call this function after an ajax jQuery call, with a param. The POST give me a json array, and I need to use the previous funct like this
$.ajax({
url: myfile.php',
type: 'POST',
data: $('#contact_form').serialize(),
dataType: 'json',
}).done(function(data) {
str = '';
$.each(data, function(index) {
$('#message').html(" <?=__('"+index+"')?> ");
});
})
The problem is that the index value inside the $.each function is not passed to php...there is a way to solve it or i have to do something like this?
$.each(data, function(index) {
switch(index):{
case 1: $('#message').html(" <?=__('1')?> "); break;
case 2: $('#message').html(" <?=__('2')?> "); break;
case 3: $('#message').html(" <?=__('3')?> "); break;
...
}
});