Lance Pollard
Lance Pollard

Reputation: 79288

Make ajax POST without requiring a response?

Is there a way to make an $.ajax POST request:

  1. without requiring a response
  2. so the server doesn't even try to return anything

Are there some HTTP headers to accomplish this? The goal would be to track statistics with minimal server and client request processing.

Upvotes: 4

Views: 1807

Answers (2)

Remi
Remi

Reputation: 21175

If it is no problem in terms of security, and the amount of data you send is at maximum 2K minus the length of your URL, use a GET request instead. A GET request sends only one TCP packet, instead of two packets as a POST request does (first the header, then the data).

Upvotes: 1

EricLaw
EricLaw

Reputation: 57085

The server should return a HTTP/204 No Content response. That's as close as you can get.

Upvotes: 6

Related Questions