'Why ping attribute not working correctly in html5

Hi I'm building an tracking system for my project and I'm try to use ping attribute, but this attribute not working correctly on localhost.

Here is my code with php

echo "<a href='".$r_url."' ping='/redirect?url=".$r_url."'>";

Can anybody tell me what's wrong with this code.



Solution 1:[1]

Based on your post and the information you gave in the comments, you are trying to redirect through the link in the ping attribute.

In the W3C documentation:

The ping attribute specifies a list of URLs to be notified if the user follows the hyperlink.

Which means that the user is not directly redirected to this URL, instead this happens:

  1. User clicks on the link
  2. The browser sends a POST request to the URL in the ping attribute
  3. The browser redirects the user to the URL in the href attribute

If you want to redirect through a URL, simply put your redirection URL in the href attribute:

echo "<a href='/redirect?url=".$r_url."'>";

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1