[英]My json request will not fire a beforeSend request.. Can't seem to figure out why
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. 当我发送AJAX请求时,
console.log
不会启动。
What do you think the problem is? 您认为问题是什么?
beforeSend(jqXHR, settings) beforeSend(jqXHR,设置)
A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x , XMLHTTPRequest) object before it is sent.
一个预请求回调函数,可用于在发送之前修改jqXHR(在jQuery 1.4.x ,XMLHTTPRequest)对象中。 Use this to set custom headers, etc. The jqXHR and settings maps are passed as arguments.
使用它来设置自定义标题等.jqXHR和设置映射作为参数传递。 This is an Ajax Event.
这是一个Ajax事件。 Returning false in the beforeSend function will cancel the request.
在beforeSend函数中返回false将取消请求。 As of jQuery 1.5, the beforeSend option will be called regardless of the type of request.
从jQuery 1.5开始,无论请求的类型如何,都将调用beforeSend选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.