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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:33:49+00:00 2026-06-15T10:33:49+00:00

I have a Ajax form in my asp.net mvc application, which has a onSuccess

  • 0

I have a Ajax form in my asp.net mvc application, which has a onSuccess callback as below:

function onSuccessReport(context)
        {
            $('reportChart').empty();

            var line1=@Html.GetStrippedString(context.Expenses);
}

I defined a html helper which accept an string an manipulte it and return a string.

What I pass to onSuccessReport, is a json result which has a structure like this:

enter image description here

But I cant send context.Expenses and the application throws syntax error.

How can I send a javascript variable to my helper?

Thanks

Edited:
The error in my view

****Error 1 The name ‘context’ does not exist in the current context****

C# method

json = json.Replace("\"Date\":", string.Empty);

            json = json.Replace("\"Total\":", string.Empty);

            json = json.Replace('}', ']');

            json = json.Replace('{', '[');

            return MvcHtmlString.Create(json);
  • 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-15T10:33:50+00:00Added an answer on June 15, 2026 at 10:33 am

    Actually, you can send javascript values over to the server side if you use Ajax. Instead of using your helper method the way you are, just change it into an action within the Controller to return you some Json (could just be a string, number, object, etc, etc). Here is an example of what you might try out.

    View

    function onSuccessReport(context)
        {
            $('reportChart').empty();
            var expenses = context.Expenses;
            $.getJSON('@Url.Action("GetStrippedString", "ControllerName")', { expenses: expenses }, function (data) {
                //pending what you pass back as data, do whatever with it
                alert(data);
            });
     }
    

    Controller

    public JsonResult GetStrippedString(string expenses)
    {
        var result = string.Empty;
        //Do something to string
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ajax form in asp.net mvc which is as simple as this:
I am new to ASP.NET MVC, particularly ajax operations. I have a form with
Inside of an asp.net mvc partial view, I have an Ajax form that posts
I have an asp.net mvc application and i need to to use ajax in
I have an ASP.NET MVC ajax form fully working on FireFox. Here's how the
I have a form in my ASP.NET MVC 3 application that will use jquery
I have an ASP.NET MVC (using the release candidate) application that works with a
I have an ASP.Net MVC page where I want to use AJAX to update
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
I'm using asp.net mvc 3 with unobtrusive jquery validation. I have a form that

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.