У меня есть этот проект, который, кажется, работает отлично, за исключением 2 вещей. Когда я сделать POST ЗАПРОС (после некоторых АЯКС звонков до): первых: я получить error: [Errno 32] Broken pipe
на моем Chrome версии 25.0.1364.172, но все, кажется, работает нормально до сих пор. second: в firefox 19.0.2 ничего не происходит .. он добавляет csrfmiddlewaretoken
в мой url и показывает 200 и перезагружает страницу с помощью моего javascript-действия, но на стороне django ничего не делается.Django Post request работает с хромом, но не с firefox
КОД:
<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
}
});
Джанго:
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)
Как можно после работы в хроме, а не в светлячок ?? что я должен сделать, чтобы заставить его работать над обоими?
Не могли бы вы высказать свой код? –
сделано! отредактировал мой пост – psychok7