$('#lang_choice1').each(function () {
var lang = $(this).val();
$('#lang_files').empty();
$.ajax({
type: "POST",
url: '<?= site_url('translation/language/getDirContents') ?>',
data: {"lang":lang},
dataType:"json",
success: function (data) {
$.each(data,function(id,dir) //here we're doing a foreach loop round each directory with id as the key and directory as the value
{
var opt = $('<option />'); // here we're creating a new select option with for each directory
opt.val(dir);
opt.text(dir.substr(dir.lastIndexOf("\\")+1));
$('#lang_files').append(opt); //here we will append these new select options to a dropdown with the id
});
$("#lang_files").val($("#lang_files option:first").val());
}
});
return false;
});
The usage of opt.text(dir.substr(dir.lastIndexOf("\\")+1));
is causing issue in UNIX system.But in windows it works fine. In UNIX it needs to be "/" How can I make it compatible to use in both windows and unix based systems?