Cabeçalho de passe em Ajax
$.ajax({
url: "/test",
headers: {"X-Test-Header": "test-value"}
});
Lokesh003
$.ajax({
url: "/test",
headers: {"X-Test-Header": "test-value"}
});
$.ajax({
url: 'YourRestEndPoint',
headers: {
'Authorization':'Basic xxxxxxxxxxxxx',
'X-CSRF-TOKEN':'xxxxxxxxxxxxxxxxxxxx',
'Content-Type':'application/json'
},
method: 'POST',
dataType: 'json',
data: YourData,
success: function(data){
console.log('succes: '+data);
}
});
$.ajax({
type: "POST",
beforeSend: function(request) {
request.setRequestHeader("Authority", authorizationToken);
},
url: "entities",
data: "json=" + escape(JSON.stringify(createRequestObject)),
processData: false,
success: function(msg) {
$("#results").append("The result =" + StringifyPretty(msg));
}
});
$.ajax({
type: "POST",
url: "/SupportHelpText.ashx", // c# web service to get HTML data
beforeSend: function (xhr) { xhr.setRequestHeader('RequestVerificationToken', $('input[name="__RequestVerificationToken"]').val()) },
data: { 'CustomerName': 'Test Customer' },
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
})