Santhosh
Santhosh

Reputation: 20426

ajax post url issue using jquery

i request a ajax call using jquery

$.ajax{}

on url parameter i hardcoded the path as

"/Home/Ajaxpost"

its working fine with default, but i hosted in IIS so the project name included in path

like "/Project/Home/Index" so now if the request goes lik "Home/Ajaxpost" fails Action not found.

How can i dynamically set the path for ajax call.

Upvotes: 0

Views: 211

Answers (2)

putolaruan
putolaruan

Reputation: 2054

$.ajax {
location.host+'/Home/Ajaxpost'
}

location.host returns/sets the hostname and port number of the current URL.

Upvotes: 0

jerjer
jerjer

Reputation: 8760

Try using this:

$.ajax('<%=ResolveUrl("~/Home/AjaxPost")%>',{},function(){});

Upvotes: 1

Related Questions