How to pass Accept header in jQuery .load() function as It need to be passed.
You need to utilize the beforeSend
parameter in the ajax
method, since load
does not expose this functionality:
$.ajax({
url: "http://www.server.com/",
beforeSend: function(jqXHR, settings) {
jqXHR.setRequestHeader("Accept", "application/json");
},
// You need to manually do the equivalent of "load" here
success: function(result) {
$("selector").html(result);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With