0

I'm doing some AJAX requests that insert new records into a database via POST, to follow the REST methods.

However, from time to time I'm getting some errors on the server (using Apache & Django 1.5.5) saying that the post data could not be read. There are several questions talking about this on SO (e.g. IOError: request data read error). So, I'm wondering if changing the AJAX calls from POST to GET would be an "elegant solution" keeping in mind that they insert new data.

Community
  • 1
  • 1
Caumons
  • 9,341
  • 14
  • 68
  • 82
  • 1
    I think first you should figure out why this is failing. – Paulo Bu Feb 19 '14 at 15:00
  • @PauloBu The error rate is very low. Per 10.000 runs we can get 1 or 2 errors... In the related posts they say that it may be caused because the user closed or changed the page. – Caumons Feb 19 '14 at 15:03
  • 1
    Is there a reason to suspect that GET requests will be more reliable than POST requests? If so, what is it? – Ian McLaird Feb 19 '14 at 15:03
  • @IanMcLaird a GET does not cause error if the user changes the page while waiting the response, POST requests do so. – Caumons Feb 19 '14 at 15:05
  • 1
    I guess the followup there is, if the user navigates away while the post is in process, are you sure you really want to process the request at all? For something as rare as this, I think I'd be inclined to let the requests fail. – Ian McLaird Feb 19 '14 at 15:14

1 Answers1

0

if you're adding new records in a database, a post method would be better. regarding the errors, check the parameter names. You can always check for consistency with the data being sent by logging them on the server side. that way you'll know that the ajax calls are working as expected.

Ritikesh
  • 1,228
  • 1
  • 9
  • 19