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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:35:34+00:00 2026-06-03T19:35:34+00:00

I am trying to call a LoadFile() function every X seconds using setInterval, and

  • 0

I am trying to call a LoadFile() function every X seconds using setInterval, and I want to call this in my document ready function , and a scriptmanager on my aspx page sets EnablePageMethods as true.
But this doesnt seem to work and returns PageMethod not defined error.
My code is given below


<script type="text/javascript" >
    $(document).ready(function () {
        setInterval(function () {
            PageMethods.LoadFile();              
        }, 1000); 
    });
</script>

    [WebMethod]
    public void LoadFile()
    {
        Collection<string> stringcollection = new Collection<string>();
        divLogSummary2.InnerHtml = "";
        try
        {
            StringBuilder content = new StringBuilder();
            if (string.IsNullOrEmpty(logFilePath))
            {
                return;
            }

            if (File.Exists(logFilePath))
            {

                using (FileStream fs = new FileStream(logFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        while (!sr.EndOfStream)
                        {
                             stringcollection.Add(sr.ReadLine());
                        }
                    }                        

                }
                for (int i = stringcollection.Count - 30 ; i < stringcollection.Count; i++)
                {
                    divLogSummary2.InnerHtml = divLogSummary2.InnerHtml + " <BR> " +                       stringcollection[i];
                }

            }
        }
        catch (Exception)
        {

        }
    }

I am relatively new to Ajax, any help and insight is much appreciated.

Thanks,

  • 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-03T19:35:35+00:00Added an answer on June 3, 2026 at 7:35 pm

    Your method should be declared as static in order to be used with PageMethods.

    [WebMethod]
    public static void LoadFile()
    {
      .....
    }
    

    Best regards

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

Sidebar

Related Questions

I'm trying to call the HttpServerUtuility.URLDecode function in C# using Visual Studio 2005, but
Hi im trying call this function from an element, but the element id is
Trying to call this function in C without any real luck: int sendcommand(char str[256],
I trying to call 2 functions in the same page to submit jquery-ajax at
I am trying to call the stored procedure using subsonic and getting Object Reference
Trying to call the projects controller and the editproject function and pass an id
Trying to call from an android client, using the signpost oauth libs. I generated
Im trying to call the function: friend ostream& operator<<(ostream& out, stack::myItem& theItem); that is
In the following I am trying call action script function from js function. What
Am trying to call a JS script from a function library in another script.

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.