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 6688987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:28:00+00:00 2026-05-26T05:28:00+00:00

I have an ASP.NET MVC web application running from http://localhost/myappname . From jQuery, I

  • 0

I have an ASP.NET MVC web application running from http://localhost/myappname. From jQuery, I make jQuery $.ajax() calls to return partial views based on some user action. I usually call this from a view in the same controller that contains the function I am calling via Ajax. For example, a view in my Home controller has the following function (which works well):

function loadMyPartialView() {
    $.ajax({
      type: 'GET',
      url: 'Home/GetNavigationTreePV/',
      success: function (data) { onSuccess(data); },
      error: function (errorData) { onError(errorData); }
    });
    return true;
}

This above url gets resolved to http://localhost/myappname/Home/GetNavigationTreePV and the partial view is returned correctly.

Now, I am trying to use qUint to unit test my functions. In this test case, I just want to verify I get to the end of the function and return true. I have created a QUNIT controller and corresponding view (which loads my unit test JavaScript file). From the test.js file that contains my unit tests, I try to make calls to the same functions that are in my Home views, like the one above. But, since I am now running out of the QUNIT controller, the url gets resolved to http://localhost/myappname/qunit/Home/GetNavigationTreePV.

I have tried changing the url of my ajax request to /Home/GetNavigationTreePV/ (with the preceding forward slash), but when I do that I get the following url http://localhost/myappname/Home/GetNavigationTreePV.

So, to be clear, I am trying to write my ajax request in a way that will always start from the root of my MVC application, and then append the url parameter given in my $.ajax() function.

Is there an easy way to do that? Am I going about this in a weird way?

  • 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-05-26T05:28:01+00:00Added an answer on May 26, 2026 at 5:28 am

    I was able to accomplish this with straight JavaScript using window.location.pathname. See the following example:

    function loadMyPartialView() {
        $.ajax({
          type: 'GET',
          url: window.location.pathname + 'Home/GetNavigationTreePV/',
          success: function (data) { onSuccess(data); },
          error: function (errorData) { onError(errorData); }
        });
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC web application running in IIS as a subweb; let's
I have a ASP.Net MVC 2 web site, which can be visited by http://localhost/Admin/ContentMgr/
I have an ASP.NET MVC 3 Beta application running on IIS. In my web.config
I have an ASP.NET 4.0 MVC web application running on IIS 6.0 with a
I have a Asp.net MVC web application, containing mostly text. I want to put
Here's what I'm trying to do. I have an ASP.NET MVC web application, where
I have developed a MVC web application with ASP.NET MVC and im just wondering
I have one question; In my ASP.NET MVC web application have to do certain
I have to migrate a web application I made with ASP.NET MVC to a
I have integrated a Silverlight Navigation Application in an ASP.NET MVC web. However when

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.