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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:41:49+00:00 2026-05-30T13:41:49+00:00

I have a site for testing Ajax… and it works: <%@ Page Title= Language=C#

  • 0

I have a site for testing Ajax… and it works:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="AJAX.aspx.cs" Inherits="HB___test.AJAX" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function Ajax() {
            var xmlHttp;
            try {
                xmlHttp = new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
            } catch (e) {
                try {
                    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
                } catch (e) {
                    try {
                        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) {
                        alert("No AJAX!?");
                        return false;
                    }
                }
            }
            xmlHttp.onreadystatechange = function () {
                document.getElementById('chat').innerHTML = xmlHttp.responseText;
                setTimeout('Ajax()', 10000);
            }
            xmlHttp.open("GET", "ajax-Content.aspx", true);
            xmlHttp.send(null);
        }
        window.onload = function () {
            setTimeout('Ajax()', 10000);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    Kummefryser...!
    <div id="chat" class="fisk" style="width: 500px; height: 500px">
    </div>
</asp:Content>

And here is the site it’s laoding:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajax-Content.aspx.cs" Inherits="HB___test.ajax_Content" %>

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ListBox ID="lbChat" runat="server" Rows="10" Width="400px"></asp:ListBox>
    </div>
    </form>
</body>

And the codebehind for the above site:

public partial class ajax_Content : System.Web.UI.Page
    {
        grjenie31Entities gr;

        protected void Page_Load(object sender, EventArgs e)
        {
            gr = new grjenie31Entities();

            var query = from es in gr.chats
                        where es.id > ((from esh in gr.chats select esh.id).Max() - 15)
                        orderby es.timestamps descending
                        select es;

            List<chat> list = new List<chat>();
            foreach (chat chat in query)
            {
                list.Add(chat);
            }

            for (int i = 0; i < list.Count; i++)
            {
                lbChat.Items.Add("[" + list[i].timestamps + "] " + list[i].personID.ToString() + ": " + list[i].besked);
            }
            this.lbChat.SelectedIndex = this.lbChat.Items.Count - 1;
        }
    }

But when I load the site ajax-Content.aspx it start reloading freakingly fast… so in 30 seconds I can’t read the text it load in the ajax.Content.aspx site.
Any ideas??

  • 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-30T13:41:50+00:00Added an answer on May 30, 2026 at 1:41 pm

    xmlHttp.onreadystatechange fires not only on success, you should only start the new timeout on readystate 4

    furtherMore you should define a variable for the timeout to be able to clear an existing timeout before running a new.

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

Sidebar

Related Questions

I have a testing page on my site that simply lets users login. Once
For testing purposes I have and SSL certificate set up on a dev site
I have a ASP.NET MVC site using Membership Provider. I have trouble testing some
I have my site live in which i echoed few strings for testing, so
I have an Ajax.Net enabled ASP.Net 2.0 web site. Hosting for both the site
I have an asp.net mvc 3 site running locally and everything works fine. I
I have a site running on WordPress. I am testing out a new site
I have just been testing a site which uses @font-face in IE6. At first,
I'm testing a new site, and I have a div with background-color: #bbf6bb; That
So I have jFeed working on another site and i'm testing it right now

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.