Django Post request可以在chrome上工作,但不能在firefox上工作
Django Post request works with chrome but not with firefox
我有这个项目,似乎他工作得很好,除了2件事。当我做一个POST请求(之前一些ajax调用后):第一:我得到一个error: [Errno 32] Broken pipe
在我的Chrome版本25.0.1364.172,但一切似乎工作得很好。秒:在firefox 19.0.2什么也没发生。它在我的url中添加了csrfmiddlewaretoken
,并显示了200,并重新加载了我的javascript动作页面,但在django端似乎什么也没做。
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="appName">App Name</label>
<div class="controls">
<input type="text" id="appName" placeholder="App Name">
</div>
</div>
<div class="control-group">
<label class="control-label" for="appDescription">App Description</label>
<div class="controls">
<textarea id ="appDescription" placeholder="App Description" rows="3"</textarea>
</div>
</div>
<div class="form-actions">
{% csrf_token %}
<button type="submit" class="btn btn-primary" name="create" onclick="createCity('create','user')">Create</button>
</div>
</form>
javascript: $.post(url, { city_id : city_id ,type : type, city: cityStr, pois: poisStr, poisdelete: poisDeleteStr, kmz: kmzStr,kmzdelete : kmzDeleteStr,limits : limitsStr, limitsdelete : limitsDeleteStr, area_name : area_nameStr , action : actionStr , imageReplace : imageReplaceStr}, function(data,status) {
if (data=='city_already_exists')
alert(data);
else {
/*var username=window.location.pathname.split("/");
window.location = "/"+username[1]+"/smarturbia/cities";*/
alert(data);
location.reload(); //otherwise does not work with firefox
}
});
Django: class CreateCityView(LoginRequiredMixin, JSONResponseMixin, CheckTokenMixin, CurrentUserIdMixin, View):
@method_decorator(csrf_protect)
def dispatch(self, *args, **kwargs):
return super(CreateCityView, self).dispatch(*args, **kwargs)
def post(self, request, *args, **kwargs):
...
return self.render_json_response(city_json)
一个帖子怎么能在chrome中工作而不是在firefox中??我该怎么做才能让它在两者上都起作用呢?
通过更改html中的to来修复它。小错大问题1 .
相关文章:
- JS可以在Chrome中工作,但不能在Firefox中工作
- jQuery Datepicker可以在Safari中工作,但不能在FF或Chrome中工作
- Json到CSV下载,可以在chrome中工作,但不能在IE浏览器中工作
- jQuery$.post可以在chrome、safari中工作,但不能在FF中工作(声明成功回调函数未定义)
- Iframe加载调整大小在Chrome中工作,但不能在IE或Firefox中工作
- Rails Production-可以工作,但不能编辑/删除/创建记录
- Django,HTML,JS:<img src=“#">可以在HTML中工作,但不能在JS文件中工作
- 两个独立工作的javascript函数,但不能一起工作
- 漂亮的照片在Dreamweaver上完美运行;但不能在任何浏览器上在线工作
- 如何在HTML / CSS中填充垂直和滚动中间窗格(Chrome可以工作,但不能Firefox)
- RGB 到 HEX JavaScript 函数在 Chrome 中工作,但不能在 Firefox 或 Safari 中工
- 节点:zlib.gunzip 可以工作,但不能 zlib.inflate
- webview日期选择器可以在android模拟器中工作,但不能在设备上工作
- jQuery addClass/removeClass在调试期间工作,但不能正常执行
- CSS和Javascript可以在内部服务器上工作,但不能在外部工作
- 我的regex可以在regex101.com沙箱中工作,但不能在实际的javascript中工作
- 为什么jQuery可以在jSfiddle中工作,但不能在站点中工作
- Sencha Touch、Apigee JS SDK和Phonegap可以在浏览器中工作,但不能在IOS中工作
- Fancybox图像点击可以独立工作,但不能与我的其他代码一起工作
- . getelementbyid工作但不能.getelementbyid ().value