4

I successfully fetch the script using

$( document ).ready(function() {

$.getScript("http://example.org/script.js");

});

However, it always sends empty referrer to example.org. My question is, what is the correct approach to send the referrer when using that function in a programmatic way ?

HassanUsman
  • 1,787
  • 1
  • 20
  • 38
user198989
  • 4,574
  • 19
  • 66
  • 95
  • See http://stackoverflow.com/questions/1267550/changing-the-http-referer-in-javascript , http://stackoverflow.com/questions/6023941/how-reliable-is-http-referer – guest271314 Aug 09 '15 at 04:50
  • Basically, it comes down to the fact that you don't control the referrer when you're making requests in the browser. The browser decides whether to set it or not and what to set it to. One can theorize, this is for obvious reasons so the referrer cannot be manipulated from the browser (it certainly can be set to anything you want when making requests from a server, though). – jfriend00 Aug 09 '15 at 06:18
  • I don't want to manipulate the browser. I just want to send the referer (the page which fetchs the script). Maybe there is an alternate for this function, maybe another alternate function which sends the referer, I just want to know if there is any... – user198989 Aug 09 '15 at 06:53
  • What do you mean by "sending referrer" ? – AsgarAli Aug 10 '15 at 07:17
  • if you embed something, or use src="", normally it sends the referer info to the external website. but its not like that on this function. how to avoid that ? – user198989 Aug 10 '15 at 17:32
  • I just tried it on my test page, and in firebug I can see the correct Referer Request header getting set. I don't have to make any changes in your code. – vijayP Aug 12 '15 at 13:16

1 Answers1

0

You can use $('.test').load(url)

Jamal Rahani
  • 105
  • 4