SORU
15 Mart 2012, PERŞEMBE


Bir XMLHttpRequest ile POST veri gönderme

Bazı veri JavaScript XMLHttpRequest kullanarak göndermek istiyorum.

HTML: aşağıdaki form var

<form name="inputform" action="somewhere" method="post">
    <input type="hidden" value="person" name="user" />
    <input type="hidden" value="password" name="pwd" />
    <input type="hidden" value="place" name="organization" />
    <input type="hidden" value="key" name="requiredkey" />
</form>

Nasıl eşdeğer JavaScript XMLHttpRequest kullanarak yazabilir miyim?

CEVAP
15 Mart 2012, PERŞEMBE


This code bunu yapmak için nasıl gösterir.


İşte yukarıdaki bağlantıyı tekrar düşme ihtimaline karşı: bu sayfadan sadece listesini

var http = new XMLHttpRequest();
var url = "get_data.php";
var params = "lorem=ipsum&name=binny";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
        alert(http.responseText);
    }
}
http.send(params);

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • michellefeng's channel

    michellefeng

    26 Kasım 2006
  • Phlearn Photoshop and Photography Tutorials

    Phlearn Phot

    11 EKİM 2011
  • XxMinayaxX1

    XxMinayaxX1

    9 Mayıs 2012