Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get the client's bowser URL who's hitting your service from ajax call?

 
subodh gupta
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a service which is being hit by a ajax call from the client i need to know there web address is there any way to do this?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the referer HTTP header
http://en.wikipedia.org/wiki/HTTP_referrer

This value is not 100% correct since clients can block or fake it, but it is your best and easiest guess.
 
Ulf Dittmer
Rancher
Posts: 42968
73
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The OP is asking for the browser URL, not the client external IP
 
subodh gupta
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Ulf i am not looking for IP

@David this is not fool proof so many a times i might get nothing
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you also provide the JS that creates the Ajax call? you could use that to get the client URL and return that value in the the Ajax payload. People may not like it and could consider it 'snooping'.
Personally I'd stick with the referer unless it was proven to be unreliable.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
subodh gupta wrote:@Ulf i am not looking for IP

I see. "web address" *can* mean the IP address, though.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, "web address" is pretty ambiguous.

In any case, why do you need this? Maybe there's another way to solve the proble.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic