0

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.

2 Answers 2

1

Try using this:

$.ajax('<%=ResolveUrl("~/Home/AjaxPost")%>',{},function(){});
Sign up to request clarification or add additional context in comments.

Comments

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.