JQuery Ajax call without expected results

I am trying to collect some statistics about some events happening on my web page.

I assumed that I would add the onmouse event to the links I want to track and call ajax for my php tracking script.

What would be the most effective way to do this, knowing that I do not expect anything in return, and that everything should continue normally, even if it fails?

I know that there are some special HTTP calls when you do not expect the data to return. What it is? Does jQuery support? How about my php script, should it return a special HTTP header?

Any advice to make this effective is welcome.

thanks

Nathan

+4
source share
1 answer

You can send 204 no content . Google seems to be doing this on its homepage for exactly the same purpose , so that the client accesses the DNS record faster.

See this SO question about how Google uses it: Google.com and clients1.google.com/generate_204

And the definition of the status code sounds correct:

10.2.5 204 No maintenance

The server has fulfilled the request but it is not necessary to return the entity-body, and, possibly, updated meta-information will want to return. The answer MAY include new or updated meta-information in the form of entity-headers, which, if present, SHOULD contact the requested option.

If the client is a user agent, it MUST NOT change the appearance of the document from what caused the request to be sent. This answer is primarily intended to be entered without changing the active viewing of the user's agent document, although any new or updated meta-information MUST use the document currently held by the user of the active agent.

Answer 204 MUST NOT include the body of the message, and therefore always ends with the first empty line after the header fields.

+5
source

All Articles