Skip to posts
  • About

Win Web Hosting

Web Hosting Information
  • Home
  • ASP.NET
  • Cloud Hosting
  • Dedicated Servers
  • Linux Web Hosting
  • Microsoft AJAX
  • Microsoft Siverlight
  • Windows Web Hosting

Help with AJAX please.?

March 6, 2010 James 1 comment
Microsoft AJAX AJAX, help, please.

Comments

Leave a comment Trackback
  • Written by elven_rangers about 2 years ago.

    It would be helpful to know what that “some html” you are talking about actually looks like.

    At a glance, your code is actually missing the first A in AJAX. The first A stands for asynchronous which means that your code should continue to execute while the request is being process.

    Now think this: what would happen in your script if the request would take a minute (or an hour) ? You call the open() function, then the request is processed (for an hour).

    Your javascript moves to the next instruction which checks for a responseText. However since the request is still being processed, there is no response text (first check fails, second check is true, since the null responseText is different than “none”). So you get a HTML (probably representing the state of the request).

    Normally, you must use this piece of code to treat AJAX response

    oXMLHTTP.onreadystatechange=function() {
    if (oXMLHTTP.readyState==4) {
    if (oXMLHTTP.responseText == “none”) {
    alert(“No Values”);
    } else if (oXMLHTTP.responseText != “none”) {
    alert(oXMLHTTP.responseText);
    }
    }
    }

    This function will be called everytime the state of the request changes (while the rest of the js will continue to run). A state of 4 means the request was complete and has returned a result.
    In your particular case (when you are probably running the script on your local server) when you don’t have results in the query the return is nearly instantaneous so you actually have a responseText on the next line. But otherwise when the server will spend some time processing the query results, you won’t so you must rely on that readyState.

Comment Pages:

Leave a Comment

Cancel Reply

You must be logged in to post a comment.

RSS

Win Web Hosting Home Page

Cheap Windows Hosting

 

May 2012
M T W T F S S
« Apr    
 123456
78910111213
14151617181920
21222324252627
28293031  

Archives

  • May 2012 (61)
  • April 2012 (81)
  • March 2012 (82)
  • February 2012 (79)
  • January 2012 (92)
  • December 2011 (163)
  • November 2011 (205)
  • October 2011 (339)
  • September 2011 (367)
  • August 2011 (367)
  • July 2011 (322)
  • June 2011 (338)
  • May 2011 (358)
  • April 2011 (94)
  • March 2011 (40)
  • February 2011 (36)
  • January 2011 (41)
  • December 2010 (30)
  • November 2010 (40)
  • October 2010 (41)
  • September 2010 (52)
  • August 2010 (150)
  • July 2010 (165)
  • June 2010 (159)
  • May 2010 (238)
  • April 2010 (248)
  • March 2010 (202)
  • February 2010 (576)

Recent Posts

  • MVC TUTORIAL PART 7 : Adding Supplier Details Link
  • dot net course in pune. C# training in pune. asp.net training in pune
  • How To Get Black Silverlight
  • Hosting Classic ASP Applications on IIS 7.5
  • Shoothill Deep Zoom for Secret Cinema and Windows 7 Phone

Tags

.NET 2010 about AJAX Application Applications ASP.NET best Business cheap cloud Company Computing Control Create data Dedicated Development Free from help Host hosting India Introduction Linux Microsoft more need Page Part private Server servers service Services Silverlight Site Software Source Tutorial Using Video website Windows

Categories

  • ASP.NET
  • Cloud Hosting
  • Dedicated Servers
  • Linux Web Hosting
  • Microsoft AJAX
  • Microsoft Siverlight
  • Windows Web Hosting

Meta

  • Register
  • Log in
  • Valid XHTML
Powered by WordPress Web Design by SRS Solutions © 2012 Win Web Hosting