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

  • Home
  • SEARCH
  • 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 7915771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:34:11+00:00 2026-06-03T14:34:11+00:00

In my MVC app , I use getJSON for some server calls. However they

  • 0

In my MVC app, I use getJSON for some server calls.
However they do not work. Deeply buried in the jquery 1.4.2 library it breaks. For the e object the username and password do not exist.
Yet in the documentation for $.getJson I have seen there is no username and password that I should take care of.
So what is wrong with the code below?

var dataService = new function () {
    $.ajaxSetup ({   
        cache: false
    });
        addBusinessUnit = function(employeeId, businessUnitId, callback) {
            $.getJSON('<%= Url.Action("AddBusinessUnitForDepartmentAdministrator", "DataService")%>',
                { employeeId: employeeId, businessUnitId: businessUnitId },
                function(data) {
                    callback(data);
                });
        },
        deleteBusinessUnit = function(employeeId, businessUnitId, callback) {
            $.getJSON('<%= Url.Action("DeleteBusinessUnitForDepartmentAdministrator", "DataService")%>',
                { employeeId: employeeId, businessUnitId: businessUnitId },
                function(data) {
                    callback(data);
                });
        };

    return {
        addBusinessUnit: addBusinessUnit,
        deleteBusinessUnit: deleteBusinessUnit
    };

} ();

EDIT:

This is my server side code.

public ActionResult AddBusinessUnitForDepartmentAdministrator(
        int employeeId, int businessUnitId)
    {
        var input = new DepartmentAdministratorExtraDepartment(employeeId, businessUnitId);
        return new JsonResult
                   {
                       Data = input.AddNewPermission(),
                       JsonRequestBehavior = JsonRequestBehavior.AllowGet
                   };
    }
  • 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-03T14:34:14+00:00Added an answer on June 3, 2026 at 2:34 pm

    OK I found the solution. I hope I never make this mistake again! All it was was that the JS was in it’s own file and therefore the Url.Action command could not pick up the context of the page!
    I do not know if it is possible to access a page context object in JS/Jquery, but in any case all I had to do was put in a Url parameter when calling the dataservice from the page and it worked.

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

Sidebar

Related Questions

I have an MVC app that does a lot of work with jQuery ajax
I have an ASP.NET MVC App, which use EF code First, for some reason
This is my first MVC app and I'm not sure how to use a
In an ASP.NET MVC app I use jQuery for posting data on button-click: <button
I'm trying to add simple login page to ASP.NET MVC app. I actually use
I currently use the repository pattern in my ASP.NET MVC 3 app. I use
In my Controller in a Asp.net MVC 1 app I want to use UpdateModel
I'm working on a PHP web app and I'm trying to use the MVC
I have a MVC app and using JQuery. I have anchor that I setup
So we're having some issues deploying an ASP.NET MVC app to a client site.

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.