开发者

Chrome not sending POST requests on localhost, Firefox works fine

I have copied the simple Django forms example exactly, running on localhost. The basic contact form example should submit a POST reque开发者_StackOverflow社区st when you click the Submit button.

I'm running Chrome on Mac Snow Leopard, and whenever I submit the form, the page simply reloads with an empty form: I can see from the runserver output that it's not sending a POST - instead it's sending a GET request.

If I open the same page in Firefox on Mac Snow Leopard, and submit the form, I can see it's sending a POST request (as it should be).

Looking at the source in Chrome, the form definitely says method="post".

<form action="/contact/" method="post"> 
<p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" /></p> 
<p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></p> 
<p><label for="id_sender">Sender:</label> <input type="text" name="sender" id="id_sender" /></p> 
<p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></p> 
<input type="submit" value="Submit" /> 
</form> 

External sites with POST forms seem to work OK in Chrome.

In addition, if I fill the form in incorrectly, in Chrome the page just reloads, with a GET request, as before; in Firefox the form gets validated, as it should.

I've tried with other POST forms on localhost and got the same result.

I know Chrome for Mac has its quirks, but what on earth is going on?


This is likely being caused by Chrome treating each file:// URL as a different domain. Try launching Chrome with the --allow-file-access-from-files option and see if that helps.

Update: You'll have to close all existing Chrome instances and launch a fresh instance with that option to notice any difference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜