• Nazariy qism
  • Metod Tavsifi
  • Empire Burlesque




    Download 3.41 Mb.
    bet1/3
    Sana01.04.2024
    Hajmi3.41 Mb.
    #184609
      1   2   3
    Bog'liq
    6-10 (1) (2)


    6. LABORATORIYA ISHI


    Mavzu: AJAX asosida tarmoq dasturini yaratish


    Ishning maqsadi:
    Java dasturlash XMLHttpRequest obyektidan foydalanib AJAX asosida tarmoq dasturini yaratish.
    Topshiriq:
    Talaba laboratoriya ishi uchun shaxsiy topshiriq oladi. Bu topshiriq bo‘yicha talaba AJAX asosida tarmoq dasturini yaratadi. Har bir talaba uchun shaxsiy topshiriq beriladi.
    Nazariy qism:
    AJAX (Asinxron JavaScript va XML) bu ko‘plab veb-texnologiyalardan foydalangan holda klient tomonida asinxron veb-ilovalarni yaratuvchi vositalar to‘plami. Ajax yordamida veb-ilovalar sahifasining ko‘rinishi va ishiga xalaqit bermasdan ma’lumotni serverdan (fonda) asinxron ravishda yuborishi va qabul qilishi mumkin. Ajax veb-sahifalar tarkibini dinamik ravishda butun sahifani qayta yuklamasdan o‘zgartirishga imkon beradi.
    AJAX imkoniyatlari:

    • Sahifani qayta yuklamasdan veb-sahifani yangilash

    • Sahifa yuklangandan so‘ng serverdan ma’lumotlarni so‘rash

    • Sahifa yuklangandan so‘ng serverdan ma’lumotlarni qabul qilish

    • Serverga ma’lumotlarni orqa fonda yuborish


    6.1- rasm. AJA XMLHttpRequest obyekti.

    Barcha zamonaviy brauzerlar XMLHttpRequest obyektini qo‘llab-quvvatlaydi.


    Fonda veb-server bilan ma’lumot almashish uchun XMLHttpRequest obyektidan foydalanish mumkin. Bu shuni anglatadiki, butun sahifani qayta yuklamasdan, veb-sahifaning qismlarini yangilash mumkin.
    var xhttp = new XMLHttpRequest();
    Xning ishlashi



    6.2- rasm. Ajax texnologiyasi asosida Veb ilova
    6.1- jadval
    XMLHttpRequest obyekt metodlari

    Metod

    Tavsifi

    new XMLHttpRequest()

    Creates a new XMLHttpRequest object

    abort()

    Cancels the current request

    getAllResponseHeaders()

    Returns header information

    getResponseHeader()

    Returns specific header information

    open(method, url, async, user, psw)

    Specifies the request
    method: the request type GET or POST
    url: the file location
    async: true (asynchronous) or false (synchronous)
    user: optional user name
    psw: optional password

    send()

    Sends the request to the server
    Used for GET requests

    send(string)

    Sends the request to the server.
    Used for POST requests

    setRequestHeader()

    Adds a label/value pair to the header to be sent

    Serverga so‘rov jo‘natish:

    • xhttp.open("GET", "ajax_info.txt", true);
      xhttp.send();

    • xhttp.open("POST", "demo_post.asp", true);
      xhttp.send();

    • xhttp.open("POST", "ajax_test.asp", true);
      xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhttp.send("fname=Henry&lname=Ford");

    • xhttp.open("GET", "ajax_info.txt", false);
      xhttp.send();

    6.2- jadval


    Server javobi


    Download 3.41 Mb.
      1   2   3




    Download 3.41 Mb.