When i am doing ajax request with js i am getting 'Referrer Policy:no-referrer-when-downgrade'
Solution 1
I found my error, it was very stupid. The problem was that i was using an a
tag for when a user is clicking and then executing the ajax request, but the problem was that i have written href=''
**an empty href inside the a tag and that's why everything was mixing up.** Very stupid mistake i hope this will help to someone else have made the same error, but to be honest i don't believe someone else can make the same mistake, lol :D thanks all for your answers!
The fix is simple, just change it to button
tag or inside the a
tag just put #
for example, but i prefer to change it with a button tag myself.
Solution 2
Please try to add in head section of your code
<meta name="referrer" content="no-referrer" />
Comments
-
Dimitar about 2 years
I am trying to send https://myownserver.com/page.php to https://myownserver.com/page2.php and I am getting:
Referrer Policy:no-referrer-when-downgrade
. This is using POST request using jquery and ajax. This is my code:$('.dSettings').click(function() { $.post('https://myownserver/page2.php', {bookid: '<?= $book['BookID']; ?>', userid: '<?= $_SESSION['Login']['UserID']; ?>', del: 'delete'}, function (data) { // do something with the data }); });
The problem is that i can open the page2.php from a GET request and using PostMan i can send POST request without any problems. I really don't get where the problem can be. Any help will be grateful!
EDIT: I am using Google Chrome, if someone need this information. My Request Headers are:
Provisional headers are shown Accept:*/* Content-Type:application/x-www-form-urlencoded; charset=UTF-8 Origin:https://myownserver.com Referer:https://myownserver.com/page.php User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 X-Requested-With:XMLHttpRequest
EDIT2: I must say that I have 2 more ajax request to the same page2.php and they are working correctly both returning:
Referrer Policy:no-referrer-when-downgrade
, but alsoStatus Code: 200
and the one that is not working I am getting on Status Code:(canceled)
EDIT3: Part of my html code firing the ajax request
<a href="" class="dSettings">Do something, go somewhere</a>
-
KIKO Software over 6 yearsDid you forget the '.com' in the domain? Or is this just a typo in your question?
-
Dimitar over 6 yearsit is just a typo, sorry. i am getting the domain name from php server value so it is the right one.
-
-
Dimitar over 6 yearswhat kind of protocols do you mind? I am using https for both links.
-
Dimitar over 6 yearswell that will probably will not work as i am using a class that is modifying the code when the page is send to page2.php. Then the php module Page2Module will handle the job and actually i am not displaying anything on page2 web page I am only modifying the database and after that just refreshing the page.php
-
Dimitar over 6 yearsbtw, i have read this, but i didn't get it. i am doing https to https request.
-
Priya over 6 yearsYou need to add this on your page.php file
-
Dimitar over 6 yearsyes i did, but it is not working. as my page.php is empty and actually it should not load at all, but i tried to adding it, but it did not work.
-
rottitime about 6 yearsDowngrading this reply as no full answer and solution given