Results 1 to 2 of 2

Thread: How to call backend code from js?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003

    Question How to call backend code from js?


    Iím new to ASP NET MVC (NetCore 3.1), how to call a method from js?

    Public async Task(int) Mytest(int _i)
        return _i*5;
    Just a simple code example, how to call and get its return value from js?

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Manchester uk

    Re: How to call backend code from js?

                url: '/ControllerName/ControllerMethod',   // eg if your controller is call UserController and you method is GetUser then = '/User/GetUser'
                method: 'GET',
                data: { argumentName: argumentValue },
                success: function (Result) {  //Result is your return item which can be a single property or an object
                    // you could then pass the result to a textbox on the page for instance
                    $("#txtUserName").text = Result;
                error: function () {
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width