-1
O código seguinte não carrega url. O que está errado?
var token = "XfdfdffddfdfdfferrrrrrrrrrreeeeeeeeeeJ777K";
var url = "https://producao-talcoisa.com/api/Produto/PesquisarConteudo/";
$.ajax({
url : url,
type : 'GET',
contentType : "application/json",
beforeSend: token,
error : onError,
success : onSuccess
});
tokenSession = null;
var setHeader = function(xhr) {
xhr.setRequestHeader('tokenApp', token);
if (token.tokenSession != null) {
xhr.setRequestHeader('token', token.tokenSession);
}
};
function onSuccess() {
console.log("sucesso");
// ToastMessage.showMessage("Sucesso");
}
function onError() {
console.log("Erro");
// ToastMessage.showMessage("Erro");
}
Which error returns in the request?
– Alex M.
Dude, are you sure the requisition is
GET
and beforeSend receivestoken
? Try to putPOST
and send thetoken
as post and see what gives.– Alex M.
put date: '&token=' + token, this will look like https://producao-talcoisa.com/api/Produto/PesquisarConteudo/&token=Xfdffddfdfdfferrrrrrrrreeeeej777k
– Gabriel Rodrigues
I switched to POST but continues.
– Faro
if and to pass the token through the url then concatenate
url: url + token
,– Gabriel Rodrigues