Link to home
Start Free TrialLog in
Avatar of gerrie-govaerts
gerrie-govaertsFlag for Belgium

asked on

jQuery / javascript Resolve client URL

Hello

In my jQuery script I want to load content using the $.post method.
In this method I point to a specific controller etc...
Instead of using the fixed path localhost/StockManamgent ...... I would like jQuery to be able to resolve the used url for the virtual directory in IIS.

$.post("http://localhost/StockManagement/Stock/LoadBrands/" + materialId, null, function (data)


Is this possible?

Thx
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

you can see the current URL using
location.href;
http://www.w3schools.com/jsref/prop_loc_href.asp

let me know if i missed something
Avatar of gerrie-govaerts

ASKER

No I'm sorry I can't get enough information from the location object.

Here are the possible options: http://www.javascriptkit.com/jsref/location.shtml

I actually need the virtual directory of IIS, not the controller, action etc...

If the virtual directory is there in current URL, you can get it from location.href,
else you need to send it from the server side script.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did you tried the two dots : ../

For example : ../../../otherDirectory/blabla
var virtualPath = "<%=HttpRuntime.AppDomainAppVirtualPath%>";

solved my problem, so thx for giving me a good hint !

Gerrie
You're very welcome! Thanks for the points Gerrie!