Reputation: 27114
Notes
My Request
$autocomplete_xhr = $.ajax({
url: '/customers/filter.json',
contentType: "application/json",
data: { name: request.term },
dataType: 'json',
beforeSend: function(xhr) {
console.log('Inside beforeSend');
console.log(xhr);
},
When I send the AJAX request out, console.log
will not fire off.
What do you think the problem is?
Upvotes: 1
Views: 400
Reputation: 54050
clearly said in docs
beforeSend(jqXHR, settings)
A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings maps are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request.
Upvotes: 3