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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:25:47+00:00 2026-05-28T02:25:47+00:00

I have the following code as part of a jquery script to open a

  • 0

I have the following code as part of a jquery script to open a jqueryui dialog (the id value is hard-coded for testing purposes):

        open: function (event, ui) {

            $(this).load("@Url.Action("Edit", "Person",
                new
                {
                    id = Guid.Parse("28769371-7518-49db-a5ea-b9c62621a609"),
                    selectedPersonFor = Model.SelectedPersonFor,
                    selectedPersonForId = Model.SelectedPersonForId,
                    clientAccountId = Model.ClientAccountId
                })");
        },

The problem I have is that, even though my dialog opens, the controller action is never hit.

If I view the source in my browser the output produced is:

open: function (event, ui) {

            $(this).load("/Person/Edit/28769371-7518-49db-a5ea-b9c62621a609?selectedPersonFor=ClientAccount&selectedPersonForId=2a2dd3b9-a73b-4afa-8237-5a4f37736f8a&clientAccountId=00000000-0000-0000-0000-000000000000");
        },

I have found that if I hardcode the URI above into my script and replace the escaped ampersand (&) with a non-escaped ampersand (&) then my controller action gets hit.

I have tried adding a call to the replace method in my script to get rid of the escaped ampersand, but this does not help. When I look at other URI’s within the same page that are generated to call controller actions, but not within a script, I note that they have escaped ampersands within them.

There seems to be some difference in how the browser is processing the call to the controller action from the script as to how it is doing it from outside the script – and all related to the escaped ampersand.

Can someone direct me in how to overcome this problem?

Further info:

I have also tried passing the query parameters to the load function as follows:

open: function (event, ui) {

            $(this).load("@Url.Action("Edit", "Person")",
                {
                    id: @Guid.Parse("28769371-7518-49db-a5ea-b9c62621a609"),
                    selectedPersonFor: Model.SelectedPersonFor,
                    selectedPersonForId: Model.SelectedPersonForId,
                    clientAccountId: Model.ClientAccountId
                });
        },

However when I do it this way my dialog does not even open.

Edit:

In response to request to show route I provide the following (hopefully this is what was being requested):

routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

I’m just using the default routes provided with my asp.net mvc3 project.

  • 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-28T02:25:48+00:00Added an answer on May 28, 2026 at 2:25 am

    In Razor the @ operator is used to HTML encode the output => & becomes &. If you don’t want this to happen you could use the Html.Raw helper:

    var url = '@Html.Raw(Url.Action("Edit", "Person", new {
        id = Guid.Parse("28769371-7518-49db-a5ea-b9c62621a609"),
        selectedPersonFor = Model.SelectedPersonFor,
        selectedPersonForId = Model.SelectedPersonForId,
        clientAccountId = Model.ClientAccountId
    }))';
    $(this).load(url);
    

    Now let’s consider your second code snippet:

    $(this).load("@Url.Action("Edit", "Person")", {
        id: @Guid.Parse("28769371-7518-49db-a5ea-b9c62621a609"),
        selectedPersonFor: Model.SelectedPersonFor,
        selectedPersonForId: Model.SelectedPersonForId,
        clientAccountId: Model.ClientAccountId
    });
    

    If you look at the rendered HTML you will see this:

    $(this).load("@Url.Action("Edit", "Person")", {
        id: 28769371-7518-49db-a5ea-b9c62621a609,
        selectedPersonFor: Model.SelectedPersonFor,
        selectedPersonForId: Model.SelectedPersonForId,
        clientAccountId: Model.ClientAccountId
    });
    

    which obviously doesn’t work because Model.SelectedPersonForId is probably not a valid javascript variable so your are getting a javascript error. Also 28769371-7518-49db-a5ea-b9c62621a609 is not a valid javascript expression as you haven’t wrapped in in quotes.

    If you want this to work make sure you generate proper contents:

    $(this).load("/Person/Edit", {
        id: '@Guid.Parse("28769371-7518-49db-a5ea-b9c62621a609")',
        selectedPersonFor: '@Model.SelectedPersonFor',
        selectedPersonForId: '@Model.SelectedPersonForId',
        clientAccountId: '@Model.ClientAccountId'
    });
    

    Notice the @ operator used before each server side variable and not only in front of the Guid. Also notice that the values are wrapped as javascript strings.

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

Sidebar

Related Questions

I have the following jQuery code to execute when I click a button $('#substat').click(function()
I have the following code, which is run every 10ms as part of a
I have the following code block code when the document is ready: $(document).ready(function() {
I have following code on my site: backgroundImages[bg_img_path_b]=new Image(); backgroundImages[bg_img_path_b].src = bg_img_path_b; backgroundImages[bg_img_path_b].loaded=loading; //jQuery(backgroundImages[lastImage]).unbind('load.backgroundImages');
I'd like some help with the following jQuery code if possible... $(document).ready(function() { $('table.sortable').each(function()
I have the following code: for (i=1; i<=len; i++) { var optcheck = col+'|'+document.getElementById('color').options[i].value;
I have the following jQuery code (lizzy-doll is an image): var toTop = $('.lizzy-doll').css('top');
I using jQuery and have the following code, it's a partial and I want
I have a part of my present code as follows: $.getJSON(http://cross.subdomain.url.com, function (data) {
I wrote the following function as a part of a jQuery plugin I am

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.