报错 POST http://192.168.79.165:8015/marketing/manager 400 (BAD REQUEST) 解决办法
我用jQuery ajax post方法 用flask url_for 传值到后端
$.ajax({
url:"{{url_for('marketing.manager')}}",
type:'post',
dataType:'json',
// data:params,
data:{'params':'aResult'},
success:function(data){
// console.log(data)
console.log('success')
},error:function(xhr){
// console.log(xhr)
console.log('fail')
}
})
结果出问题了 报出错误 POST http://192.168.79.165:8015/marketing/manager 400 (BAD REQUEST)
----------------------------------------------------------------------------------------------------------------------------------------------------以上是问题
网上找的网址 https://segmentfault.com/q/1010000004019749/a-1020000004020013
发现问题确实是 后端用了CRSF 前端应该在ajax中加上一个关于crsf的东西
var csrf_token = "{{ csrf_token() }}";
$.ajax({
url:"{{url_for('marketing.manager')}}",
beforeSend: function(xhr, settings) {
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrf_token);
}
},
type:'post',
dataType:'json',
// data:params,
data:{'params':'aResult'},
success:function(data){
// console.log(data)
console.log('success')
},error:function(xhr){
// console.log(xhr)
console.log('fail')
}
})
附上解决代码链接:csrf protection
--------------------------------------------------------------------------------------------------------------------------------------------------------------解决
PS:不过后端一直踩坑 POST,GET不要随意大小写哦~都是泪
报错 POST http://192.168.79.165:8015/marketing/manager 400 (BAD REQUEST) 解决办法的更多相关文章
- npm install 报错 error Unexpected end of JSON input while parsing near '...sShrinkwrap":false,"d' 解决办法
npm install 报错 : error Unexpected end of JSON input while parsing near '...sShrinkwrap":false,& ...
- 批量改主机名报错:Address 192.168.43.117 maps to bogon, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
ssh连接批量修改主机名报出以下提示: [root@bqh-nfs- ~]# vim modfilyhostname.sh [root@bqh-nfs- ~]# sh modfilyhostname. ...
- pip安装pycrypto报错:Microsoft Visual C++ 14.0 is required. 和 SSLError: HTTPSConnectionPool的解决办法
今天本打算把[Python3爬虫]网易云音乐爬虫 的代码敲一遍, 但是在安装pycrypto老是报错, 由于我计算是win10, 并且也有vs2017 python3环境下安装pycrypto的一些问 ...
- appium===报错Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.的解决办法
要解决的问题:appium在androidV7.0系统上运行时报错 Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.a ...
- Web 项目报错No suitable driver found for jdbc:mysql://localhost:3306/book 的一个解决办法
确认jar包加入到了build path中,然后注意版本是否与数据库相配,还要留意将jar包放入WEB-INF下的lib文件夹中
- 报错 Inferred type 'S' for type parameter 'S' is not within its bound; 解决办法
出现情况: Inferred type 'S' for type parameter 'S' is not within its bound; should extends xxxxxx 出现这种问题 ...
- appium===报错adb server version (31) doesn’t match this client (39); killing…的解决办法
当使用在cmd窗口调用adb shell命令的时候 提示如下: adb server version (31) doesn't match this client (39); killing...er ...
- 解决Zookeeper报错:conf is not executed because it is not in the whitelist的解决办法
1.echo wchp | nc localhost 2181 ,通过路径列出服务器 watch 的详细信息,且它会输出一个与 session 相关的路径.但是出现下面的错误. [root@xg61 ...
- 【转】ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.165' (113)
原文转自:http://blog.csdn.net/chengyuqiang/article/details/54285857 1.程序报错: com.mysql.jdbc.exceptions.jd ...
随机推荐
- 迷你MVVM框架 avalonjs 1.2发布
avalon1.2 带来了许多新特性,让开发更轻松!详见如下: 升级路由系统与分页组件. 对ms-duplex的绑定值进行增强,以前只能prop或prop.prop2,现在可以prop["x ...
- 代替Reflection(反射)的一些方法(转)
作者:JustRun 林肯: http://www.cnblogs.com/JustRun1983/p/3830764.html 代替Reflection(反射)的一些方法(转) 2014-07-08 ...
- NGUI中显示DrawCall详细信息
[NGUI显示DrawCall详细信息] UIDrawCall中有个宏,SHOW_HIDDEN_OBJECTS,默认为关闭状态.将此宏打开,NGUI即会将DrawCall对象显示在Hierarchy中 ...
- Fundamentals of Garbage Collection
[Fundamentals of Garbage Collection] 1.Reclaims objects that are no longer being used, clears their ...
- Mac 下输入特殊字符
[Mac 下输入特殊字符] 快捷键是 Control + Commans + Space
- Git学习笔记-----下载GitHub上某个分支的代码
在GitHub上的仓库里,往往建有几个分支,如果只是想下载某个分支的代码,怎么办呢? 1.需要知道远程分支的名称,及远程分支所在的Git仓库 2.按下面指令下载 git clone -b 远程分支名称 ...
- Linux CentOS6 mysql rpm安装
mysql rpm文件下载地址:https://dev.mysql.com/downloads/mysql/ 选择操作系统及版本: 点击5.6版本链接 将下载好的文件上传至服务器 下面开始安装: 检查 ...
- CentOS 7 装好系统一些优化
1.禁用SELINUX vi /etc/sysconfig/selinux 设置为disabled 2.同步时间*/20 * * * * /usr/sbin/ntpdate pool.ntp.org ...
- zz如何让你的婚姻天长地久?
如果天长地久意味着一列永不出轨的火车,下面有关婚姻生活的战略就像制定一张准确的运行时刻表.因为成功的婚姻并非源于机运,所谓的七年之痒也不是空穴来风.对那些已婚男人来说,他们需要计划——为了一年比一年过 ...
- 访问localhost的phpmyadmin出现访问被拒绝
原因是:没有配置MySQL数据库密码. 1.打开D:\wamp\apps\phpmyadmin x.xx找到config.inc.php. 修改并保存: $cfg['Servers'][$i]['us ...