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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:33:48+00:00 2026-05-28T17:33:48+00:00

I want set result to variable from MVC controller method. function someFunction(){ var result;

  • 0

I want set result to variable from MVC controller method.

function someFunction(){ 
    var result;
    $.Ajax{    
        //??? 
    }
    return result; 
}

//In comparison to c++

int f() { //just! return result; }

P.S.: It is not async, it should be sync function call in order to return value to the function body.

  • 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-28T17:33:50+00:00Added an answer on May 28, 2026 at 5:33 pm

    set up a controller

    public ActionResult Foo(){
    
    return Content("Hello Anton");
    }
    

    set up the ajax request, remember to make it async:false, which is by default true, in order to return the value

    function greeting(){
       var x= $.ajax({
                url:'/ControllerName/Foo',
                async:false,    
              });
       return x.responseText();
    }
    

    now you can call the function like

    var v = greeting();
    alert(v); //if every thing goes well you will see "Hello Anton"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display result set of Years between From date - To date
I want to store a large result set from database in memory. Every record
I want to put random output from my result set (about 1.5 mil rows)
I have a MYSQL stored procedure SP1() that returns a result set. I want
I have two results from a data set. I want to add both results
In my mainline I want to read a variable from the current template context,
Is it possible to set a user variable based on the result of a
I must be overlooking something simple. I'm setting a variable from a query result
I'm inserting the result set returned from a CLR stored procedure into a table
I want to retrieve a set of records from a database, do a rs.next()

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.