XMLHttpRequest() kullanırken verilerin alınmasıyla ilgili iki sorum var. İstemci tarafı javascript'te. Sunucu tarafı python'tadır.XMLHttpRequest() kullanırken python'da POST verileri nasıl alınır()
- Python tarafındaki verileri nasıl alırım/işlerim?
- HTTP isteğine nasıl yanıt veririm?
İstemci tarafı
var http = new XMLHttpRequest();
var url = "receive_data.cgi";
var params = JSON.stringify(inventory_json);
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
GÜNCELLEME: Ben cgi.FieldStorage() ancak tam olarak nasıl girişimim bana sonrası isteği için bir sunucu hatası alıyorum ile sona erdi kullanmalıdır biliyor musunuz?.