我用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) 解决办法的更多相关文章

  1. 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,& ...

  2. 批量改主机名报错: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. ...

  3. pip安装pycrypto报错:Microsoft Visual C++ 14.0 is required. 和 SSLError: HTTPSConnectionPool的解决办法

    今天本打算把[Python3爬虫]网易云音乐爬虫 的代码敲一遍, 但是在安装pycrypto老是报错, 由于我计算是win10, 并且也有vs2017 python3环境下安装pycrypto的一些问 ...

  4. 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 ...

  5. Web 项目报错No suitable driver found for jdbc:mysql://localhost:3306/book 的一个解决办法

    确认jar包加入到了build path中,然后注意版本是否与数据库相配,还要留意将jar包放入WEB-INF下的lib文件夹中

  6. 报错 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 出现这种问题 ...

  7. 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 ...

  8. 解决Zookeeper报错:conf is not executed because it is not in the whitelist的解决办法

    1.echo wchp | nc localhost 2181 ,通过路径列出服务器 watch 的详细信息,且它会输出一个与 session 相关的路径.但是出现下面的错误. [root@xg61 ...

  9. 【转】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 ...

随机推荐

  1. 搭建https+nginx服务器

    搭建https+nginx的服务器,主要是安装ngnix和使用openssl生成自签证书,并在nginx中配置的过程   一.安装环境 1.安装opnssl(ssl支持) https://www.op ...

  2. 自学jquery,下午实现前后台交互--成为牛逼的女程序员

    希望周末能够把搜索质量对比的页面做出来!!! 牛逼的薰衣草程序员,fighting

  3. SpringBoot中使用LoadTimeWeaving技术实现AOP功能

    目录 1. 关于LoadTimeWeaving 1.1 LTW与不同的切面织入时机 1.2 JDK实现LTW的原理 1.3 如何在Spring中实现LTW 2. Springboot中使用LTW实现A ...

  4. Python dict() 函数

    Python dict() 函数  Python 内置函数 描述 dict() 函数用于创建一个字典. 语法 dict 语法: class dict(**kwarg) class dict(mappi ...

  5. 【总结整理】关于挪车和虚拟号的思考-转载v2ex

    https://www.baidu.com/link?url=A7wiF1JpOkT6Juo0nNHKcum0OiQsnRj-EZkQfjc3xB-noUeLy3HEY-4plbFmPmuJ& ...

  6. Qt Pro file

    Qt keys qmake Manual Building Common Project Types #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...

  7. How to use mouse to moving windows of not have title bar?

    How to use mouse to moving windows of not have title bar? #include "widget.h" #include < ...

  8. mybatis总结回顾

    1.mybatis的介绍 轻量级数据持久层框架,替代hibernate 2.mybatis的入门 导包-->配置文件(类名.xml.SqlMapConfig.xml) 类名.xml:放映射.sq ...

  9. Ninject在.NET WebForm和MVC中的使用

    1.建立项目:Models/BLL/DAL/IBLL/IDAL/WebSite 2.WebSite要引用其余几个项目 3.NuGet中搜索Ninject,安装 Ninject.Ninject.Web. ...

  10. MVC架构思想