在angularjs中重复ajax调用 [英] duplicate ajax calls in angularjs

查看:87
本文介绍了在angularjs中重复ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 express-jwt 构建一个宁静的api.现在客户端正在重复进行ajax调用,对于第一个,发起者是angularjs,对于第二个,发起者是另一个.第一个获得204作为响应代码,第二个获得200作为响应代码.我尝试调试以获取此重复请求的源,但我无法.

I am using express-jwt to build a restful api. Now the client is making duplicate ajax calls, for the first one the initiator is angularjs and for the second one the initiator is other. The first one gets 204 as the response code and the second one gets 200 as the response code. I tried to debug to get to the source of this duplicate requests, but I am not able to.

下面是状态代码为204的标题的详细信息

Below is the header details for the one with 204 status code

下面是状态代码为204的标题的详细信息

Below is the header details for the one with 204 status code

任何人都可以提出问题所在吗?

Can any one suggest what could be the issue?

推荐答案

第一个调用是OPTIONS类型.如果页面和api不在同一个域中,那是浏览器发送的飞行前呼叫.

The first call is OPTIONS type. That's a pre-flight call which a browser sends if the page and api are not on same domain.

此调用的目的是处理CORS.后端通常需要发送允许的请求方法类型(GET,POST等).然后,如果所需的请求类型在返回的请求中,浏览器将发送真实的呼叫.

The purpose of this call is to deal with CORS. Backend usually needs to send the allowed request method types (GET, POST etc.). The browser will then send the real call if the desired request type is among those returned.

这是响应头的示例.

Here's a sample of the response headers.

出于所有意图和目的,您都可以忽略它.它不包含任何通常有用的有效负载或返回数据.

You can ignore it for all intents and purposes. It does not contain any normally useful payload or return data.

看看 Chrome中的AJAX发送选项而不是GET/POST/PUT/DELETE?以获取更多信息.

这篇关于在angularjs中重复ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆