3
Good afternoon, I have the following piece of code:
function getData(){
var url = "http://teste.com";
var data = "";
$.get(url, function(response){
serverResponse = response;
for(i in response.content){
data +='\
<tr>\
<td>'+response.content[i].TesteId+'</td>\
<td>'+response.content[i].TesteNome+'</td>\
<td>'+response.content[i].TesteEmail+'</td>\
</tr>';
}
$('#corpotabela').empty();
$('#corpotabela').append(data);
var width = new Array();
$(".table-body tr:eq(0)").find('td').each(function (position){
width[position] = $(this).outerWidth();
});
$(".table-header tr").find('th').each(function (position){
$(this).css("width", width[position]+2);
});
});
}
However, to be able to do this request I need to send a token in the header. I can do this using this jQuery method?
Test pass a configuration object with
{url: url, beforeSend: function(xhr){xhr.setRequestHeader('X-Token', 'meu-valor');}
.– Sergio