Academic Tutorials



English | French | Portugese | Dutch | Italian
Google

on-line

Haupt Quellenprogramme E-Bücher Downloads Mit uns in Verbindung treten Über uns

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


AJAX Beispiel
Previous Next



  • AJAX ist hauptsächlich, eine schnelle, dynamische Web site zu errichten, aber gewohnt Hilfsmittel auch zu speichern.


  • Beispiel
    Diesen Schritten folgen, um Anwendungen eines Netzes zu errichten:
  • Einen Text erhalten
  • Von XML erhalten
  • Schreiben dem Körper
  • Einen Text bekanntgeben
  • 1) Einen Text erhalten:
    <html>
    <head>
    <script>
    function submitForm()
    {
      var req = null;
      if(window.XMLHttpRequest)  req = new XMLHttpRequest();
      else
        if (window.ActiveXObject)  req = new ActiveXObject(Microsoft.XMLHTTP);

      req.onreadystatechange = function()
      {
        if(req.readyState == 4)
        {
           if(req.status == 200)
               document.ajax.dyn="Received:" + req.responseText;
           else
               document.ajax.dyn="Error code " + req.status;
      };
      req.open( GET", "data.xml", true);
      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
      req.send(null);
    }
    </script>
    </head>

    <body>
    <FORM method="POST" name="ajax" action="">
       <INPUT type="BUTTON" value="Submit" ONCLICK="submitForm()">
       <INPUT type="text" name="dyn" value="">
    </FORM>
    </body>
    </html>
    Comments on the code:
    new ActiveXObject(Microsoft.XMLHTTP)

    This constructor is only for Internet Explorer.

    new XMLHttpRequest()

    This constructor is only for any other browser including Firefox.

    http.onreadystatechange

    An anonymous function is assigned to the event indicators

    http.readyState == 4

    The 4 state means for the response is ready to send and sent by the server

    http.status == 200

    This status means ok, otherwise some errors code is returned, 404 for example.

    http.open( "POST", "data.xml", true);

    POST or GET
    URL of the scripts to execute.
    true for asynchronous .

    http.setRequestHeader("Content-Type", "applications/x-www-form-urlencoded");

    This is for POST method only.

    http.send(document.getElementById("TYPEDTEXT").value);

    Sends data to the server. Data comes from the "TYPEDTEXT" variable filled throught the form by the user.




    2) Von XML erhalten

    Um Daten von einer XML Akte müssen uns zu erhalten diese Linie ersetzen:

    document.ajax.dyn=""Received:" + req.responseText;

    durch diesen Code

    var doc = req.responseXML; // assign the XML file to a var
    var element = doc.getElementsByTagName('root').item(0); // read the first element with a dom's method
    document.ajax.dyn.value= element.firstChild.data; // assign the content of the element to the form
    3) Schreiben dem Körper

    In diesem Beispiel wird der gelesene Text in den Körper der Seite und nicht in ein textfield eingesetzt. Der Code folgend ersetzt den textfield Formgegenstand und das zweite Teil ersetzt die Anweisung in die Javascriptfunktion.

    <div id="zone">
    ... some text to replace ...
    </div>
    document.getElementById("zone").innerHTML = "Received:" + req.responseText;
    4) Einen Text bekanntgeben

    In diesem Beispiel wird ein Text zum Bediener geschickt und wird zu einer Akte geschrieben. Der Anruf zur „geöffneten“ Methode ändert, ist das Argument PFOSTEN-Methode, und Methode „senden“ hat auch jetzt einen Wert für Argument.

    req.open("POST", "ajax-post.xml", true);
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    req.send(document.getElementById("dyn").value);




    Previous Next

    Schlüsselwörter: ajax Beispiel Tutorial, ajax Beispielhtml page, ajax Beispiel req, xml Dokument


    HTML Quizes
    HTML Quiz
    XHTML Quiz
    CSS Quiz
    TCP/IP Quiz
    XML Quizes
    XML Quiz
    XSL Quiz
    XSLT Quiz
    DTD Quiz
    Schema Quiz
    XForms Quiz
    XSL-FO Quiz
    XML DOM Quiz
    XLink Quiz
    XQuery Quiz
    XPath Quiz
    XPointer Quiz
    RDF Quiz
    SOAP Quiz
    WSDL Quiz
    RSS Quiz
    WAP Quiz
    Web Services Quiz
    Browser Scripting Quizes
    JavaScript Quiz
    VBScript Quiz
    AJAX Quiz
    DHTML Quiz
    HTML DOM Quiz
    WMLScript Quiz
    E4X Quiz
    Server Scripting Quizes
    ASP Quiz
    PHP Quiz
    PERL Quiz
    SQL Quiz
    ADO Quiz
    .NET (dotnet) Quizes
    Microsoft.Net Quiz
    XML Web Services Quiz
    ASP.Net Quiz
    .Net Mobile Quiz
    C# : C Sharp Quiz
    ADO.NET Quiz
    VB.NET Quiz
    Multimedia Quizes
    SVG Quiz
    Flash Quiz
    Media Quiz
    SMIL Quiz
    Web Building  Quizes
    Web Browsers Quiz
    Web Hosting Quiz
    W3C Quiz
    Web Building Quiz
    Web Quality Quiz
    Web Semantic Quiz
    Web Careers Quiz
    Java Quizes
    Java Quiz
    JSP Quiz
    Servlets Quiz
    Struts Quiz
    EJB Quiz
    JMS Quiz
    JMX Quiz
    Programming Langauges Quizes
    C Quiz
    C++ Quiz
    Visual Basic Quiz
    Data Structures Using C Quiz
    Soft Skills Quizes
    Communication Skills Quiz
    Time Management Quiz
    Project Management Quiz
    Team Work Quiz
    Leadership Skills Quiz
    Corporate Communication Quiz
    Negotiation Skills Quiz

    Privacy Policy
    Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.