Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:41:02+00:00 2026-06-13T22:41:02+00:00

This is probably very simple, but i’ve been stuck for a while. I have

  • 0

This is probably very simple, but i’ve been stuck for a while.

I have a user-control which is calling a method like this:

 $(document).ready(function () {
        $("#myabtags").tagit({
            tagSource: function (request, response) {
                $.ajax({
                    type: "POST",
                    url: "Services/ForumOperationService.svc/GetTags",
                    datatype: "json",
                    contentType: "application/json; charset=utf-8",
                    data: '{"prefix":"' + request.term + '"}',
                    success: function (data) {
                        response(data.GetTagsResult);
                    }
                });
            }
        });
    });

However, this user control is used several places on my website. For instance at root, /Admin/ and several others.

I would want to do something like:

url: "~/Services/ForumOperationService.svc/GetTags"

How do you do that in jQuery ?

Attemps:

Putting slash in front, like

url: "/Services/ForumOperationService.svc/GetTags"

That doesn’t work. I get a 404 error back: http://localhost:16481/Services/ForumOperationService.svc/GetTags" (gives 404).

Instead it should be

http://localhost:16481/Client/Services/ForumOperationService.svc/GetTags"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:41:03+00:00Added an answer on June 13, 2026 at 10:41 pm

    If your application is always in the same location, use an absolute path ("/Services/ForumOperationService.svc/GetTags"). However, if you deploy the same codebase to multiple sites, which may have different root paths, I use this trick:

    It works like this: I assume all JS scripts for my application are in a folder, such as Scripts. I then have a common JS file that has utilities, including a place to keep the absolute root URL and a method to make absolute URLs. Then I search for a script block with that src, and extract the root URL.

    (function($)
    {
        $.myapp = {};
        var $a = $.myapp;
    
        $.extend($a, {
            rootUrl: '',
            makeAbsoluteRootPath: function(path) {
                return path.replace('~/', $a.rootPath);
            }
        });
    
        var tag = $('script[src*="scripts"]').first();
        if (tag.length > 0) {
            var url = tag.attr('src').replace(/\/?(scripts).+$/i, '/');
            $a.rootPath = url;
    
        }
    
    })(jQuery);
    

    Now you can resolve the absolute root path dynamically:

    url: $.myapp.makeAbsoluteRootPath("~/Services/ForumOperationService.svc/GetTags");
    

    http://jsfiddle.net/HackedByChinese/tRMSj/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is another probably very simple question, but I haven't been able to find
This is probably a very simple fix but I've been unable to find an
This is probably very simple, but my attempts (guided by Intellisense and MSDN) have
Okay, this is probably very simple but, I have the below checks (not at
This is probably a very simple question but I have a confusion about the
This is probably very simple, but I can't work it out. I have this
This is probably a very simple question, but at this time I have myself
This is probably very simple but it's really confusing me. When I implement the
This is probably a very simple question but I'm a little confused how this
I know this is probably a very simple question but how would I do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.