javascript - AttributeError: 'NoneType' 对象没有属性 'get' //500(内部服务器错误)
问题描述
这不是从 crome 扩展发送任何数据,我正在尝试使用提到的 url 将 json 字符串发送到服务器,该 url 表示没有返回任何类型的对象,
var xhr = new XMLHttpRequest();
var ur = "http://127.0.0.1:8080/animal";
var dat = {"subject":"subject"};
xhr.open("POST", ur, true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
// do something with response
console.log(xhr.responseText);
}
};
xhr.send(dat);
}
};
xhr.send(dat);
解决方案
你不能用 发送一个对象xhr.send()
,你需要序列化它。
var dat = 'subject=subject';
推荐阅读
- angular - 如何仅获取 isAllselected 函数的数据源中的过滤数据,即。角度7中的复选框列表功能“isAllSelected”
- java - Switch 语句 - JVM 内存分配、堆栈溢出
- hadoop - Hive Query:如何使用 group by 和 rank?
- reactjs - 需要选择的选择项的材质ui列表
- wordpress - Wordpress 从 http 迁移到 https 导致 CSS 文件无法加载
- php - 检查不会保存的 STRICT_TRANS_TABLES 变量时出错
- android - 当应用程序从 WhatsApp 指纹屏幕等后台恢复时,每次打开启动画面
- jquery - Essential Grid Fancybox - 无法在移动 chrome 上滚动溢出内容
- django - 在 Django 上编辑用户照片,需要一起传递 request.POST +request.FILES
- java - UI 打印 Null 值而不是 txt 文件中的文本