我用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. go_组合接口

    main函数入口 package main import ( "fmt" "learngo/retriever/mock" "learngo/retr ...

  2. 使用Git将码云上的代码Clone至本地

    1. 安装Git https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git Git的网站上有详细的分各种系统的安 ...

  3. METAL渲染是什么?

    METAL渲染是什么? Metal渲染是由苹果公司为iOS8以及更新版本开发的全新的底层渲染API.它侧重于减少GPU驱动的工作量,从而当Metal调用时,CPU的消耗将降至最低.这样一来,游戏就可以 ...

  4. 2-ubuntu下访问window的磁盘

    双系统Ubuntu无法进入Windows磁盘的解决方法 有些用户在电脑上安装了Ubuntu和Win10的双系统,正常情况下Ubuntu是可以正常访问Windows磁盘的.但是有些用户就是无法再Ubun ...

  5. 操作ini配置文件设计一个最基本的可视化数据库系统

    对于很多小项目来说,不需要搭建专门的数据库系统(例如用SQLite搭建本地数据库),这时可以用ini配置文件实现一个最基本的数据库,实现数据库最基本的增删改查功能. ini配置文件的用法参考我以前写的 ...

  6. qt5.7 安装

    http://blog.csdn.net/liang19890820/article/details/53931813#安装-qt57 安装运行出错:qt vstool 指定qt安装路径 http:/ ...

  7. radiobutton 选中的项不能去掉选择的问题

    代码如下: RadioButton rbtn = new RadioButton(getApplicationContext()); rbtn.setText(String.valueOf(item. ...

  8. http://4526621.blog.51cto.com/4516621/1343369

    http://4526621.blog.51cto.com/4516621/1343369

  9. docker daemon文件/etc/docker/daemon.json配置

    On Linux The default location of the configuration file on Linux is /etc/docker/daemon.json. The --c ...

  10. cin和gitchar的区别

    cin是iostream(输入输出类) 类下的istream(输入类)类的对象,作用是顺序输入字符串.cin.get()是cin的方法.cin.get()是C++面向对象的操作,getchar()是C ...