2013-03-14 19 views
2

我有這個項目,似乎他工作正常,除了2件事情。 當我做了POST請求(之前的一些Ajax調用後): 第一:我得到我的Chrome版本25.0.1364.172一個error: [Errno 32] Broken pipe但一切似乎好工作仍。 秒:在firefox 19.0.2沒有任何反應..它在我的url中添加了csrfmiddlewaretoken並顯示了200,並用我的javascript動作重新載入了頁面,但似乎沒有任何東西在django一側實際完成。Django Post請求使用chrome但不使用firefox

CODE:

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

哪有崗位工作中的鉻,而不是在Firefox?我應該怎麼做才能讓它在兩者上都能正常工作?

+1

請問您可以發佈您的代碼嗎? – 2013-03-14 12:53:29

+0

完成!編輯我的帖子 – psychok7 2013-03-14 12:58:44

回答

0

通過在html中更改爲固定它..小錯誤,大問題。