Tuesday, 20 August 2013

Relative URL in JQuery Post Call

Relative URL in JQuery Post Call

I have the following situation.
I developed my first MVC Asp.Net application. it runs on my server at the
following adress
http://localhost:59441/
I wrote some JQuery Post Methods that looked like this
$.ajax({
type: "POST",
url: "/CeduleGlobale/UpdateCheckBox", ...
CeduleGlobale is my ControllerName and UpdateCheckBox is my methodName
When I put the Application on the testServer, it was put in a
VirtualDirectory
hence the application is now
http://testServer/JprApplication/
no more port to specify and also an application Name
When I started to test, I quickly noticed my JQuery Post calls didn't work
anymore...
I modified them so now the URL is
/JprMvc/CeduleGlobale/UpdateCheckBox
the problem is 2 fold.
this makes it hard to test on my development machine because IIS Express
doesn't allow me to specify a virtual Directory.
I don't like hardCoding the Virtual Directory Name in the JQuery because I
dont know what name the Application will have in the production
environment and therefore i will have to modify my script before i can
install the application in production.
I am sure I am missing some basic thing to simplify this.
Thanks

No comments:

Post a Comment