简体   繁体   English

我的json请求不会触发beforeSend请求。似乎无法找出原因

[英]My json request will not fire a beforeSend request.. Can't seem to figure out why

Notes 笔记

  1. This is jQuery 1.4.4 这是jQuery 1.4.4
  2. This is not a jsonp request. 不是 jsonp请求。 Just vanilla json within my domain. 在我的域名中只是香草json。

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? 您认为问题是什么?

clearly said in docs 文档中清楚地说

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.

相关问题 似乎无法弄清楚如何在我的请求标头中设置令牌 - Can not seem to figure out how to set a token in my request header 无法弄清楚为什么此ajax请求会触发两次 - Can't figure out why this ajax request fires two times 似乎无法弄清楚为什么我的 promise 阵列不工作 - Can't seem to figure out why my promise array isn't working 我的javascript函数似乎无法正常工作。 我不知道为什么 - My javascript function doesn't seem to be working. I can't figure out why 似乎无法弄清楚为什么我的JavaScript无法在IE和Chrome中运行 - Can't seem to figure out why my javascript isn't working in IE and Chrome 似乎无法弄清楚该脚本为何不起作用 - Can't seem to figure out why the script isn't working d3:我的路径似乎在翻倍,我不知道为什么 - d3: My paths seem to be doubling up and I can't figure out why 我的CPU在Google Cloud上的使用率已达到160%,我似乎不知道为什么吗? - My CPU is reaching 160% on Google Cloud and I can't seem to figure out why? 似乎无法弄清楚为什么我的矩阵乘法函数不起作用 - Can not seem to figure out why my matrix multiplication function is not working 我的硬币游戏代码,但似乎无法弄清楚这部分 - My code of a coin game but can't seem to figure out this part
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM