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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:37:40+00:00 2026-06-04T15:37:40+00:00

javascript: var Enabled = false; function GateWay_Enabled(GateWay_Name) { PageMethods.GateWay_Enabled(GateWay_Name, onRequestComplete, onError); return Enabled; }

  • 0

javascript:

            var Enabled = false;
            function GateWay_Enabled(GateWay_Name) {
                PageMethods.GateWay_Enabled(GateWay_Name, onRequestComplete, onError);
                return Enabled;
            }

            function onRequestComplete(result) {
                Enabled = result;
            }
            function onError(result) {
                alert('Error');

            }
            var MyVariable = GateWay_Enabled('GateWay_Name');

Server Side Code (C#):

[WebMethod]
[ScriptMethod]
public static bool GateWay_Enabled(string GateWay_Name)
{
    bool Enabled = true;
    return Enabled;
}

Why is MyVariable always false?
Is there another way to write PageMethods.GateWay_Enabled(GateWay_Name, onRequestComplete, onError); as the return of the GateWay_Enabled function?
I’m looking for something like this :

var MyBoolVariable =
bool.parse(PageMethods.GateWay_Enabled(GateWay_Name,
onRequestComplete, onError));

EDIT 1:
Everything is working and there is no error for PageMethods.
EnablePageMethods in script manager is true.

EDIT 2:
I cannot put MyVariable inside the onRequestComplete() function.
I made MyVariable to make my code easier.
The real code of MyVariable is:

    GateWays = [
                        { "Cod": 1, "Enabled": GateWay_Enabled('1') },
                        { "Cod": 2, "Enabled": GateWay_Enabled('2') },
                        { "Cod": 3, "Enabled": GateWay_Enabled('3') },
                        { "Cod": 4, "Enabled": GateWay_Enabled('4') },
                        { "Cod": 5, "Enabled": GateWay_Enabled('5') },
                        { "Cod": 6, "Enabled": GateWay_Enabled('6') },
                        { "Cod": 7, "Enabled": GateWay_Enabled('7') }
                ];

I want to use this array in another place.
I can’t put it in the onRequestComplete() function.
What do I do?

  • 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-04T15:37:41+00:00Added an answer on June 4, 2026 at 3:37 pm

    Calling PageMethods is asynchronous: the line return Enabled is executed before the function onRequestComplete is called.

    Try putting whatever code you have that reads MyVariable into the onRequestComplete function, using result instead.

    After your Edit2 and comment, I’d suggest you:

    1. Refactor your PageMethod to return the whole GateWays array given an array of input IDs, to avoid making 7 AJAX calls.
    2. Make all this AJAX be called when the user clicks the link, and then put the subsequent code in the onRequestComplete method.

    Alternatively if this data doesn’t change between user clicks I’d suggest you get it on the server side.

    There’s no easy way to ensure the user-click code waits until all seven of your calls have completed.

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

Sidebar

Related Questions

For example in javascript var image = new Image(); image.onerror = function(e) { //
I have this JavaScript: var Type = function(name) { this.name = name; }; var
I am creating an object in javascript: var t = null; $.getJSON('http://localhost:53227/Home/GetData', function (data)
Let's say I have this javascript: <script language=javascript type=text/javascript> function addtext() { var newtext
I have an array in Javascript: var array = new array(); array[0] = apples;
You can backreference like this in JavaScript: var str = 123 $test 123; str
I have this piece of code in javascript: var catId = $.getURLParam(category); In my
I have opened a new window with JavaScript: var newwin = window.open('','preview','width=600,height=500'); Now I
I am doing the following in javascript: var first_last = { FName: 'John', LName:
Given a string like the following in JavaScript var a = 'hello world\n\nbye world\n\nfoo\nbar\n\nfoo\nbaz\n\n';

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.