Visualizzazione dei risultati da 1 a 6 su 6

Discussione: tichiesta httprequest

  1. #1

    tichiesta httprequest

    Salve a tutti.
    Ho una richiesta requet in background, ma la richiesta viene fatto in metodo get eccola:

    Codice PHP:
    var myRequest null;
    function 
    CreateXmlHttpReq(handler){
    var 
    xmlhttp null;
    try {
    xmlhttp = new XMLHttpRequest();
    } catch(
    e) {
    try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(
    e) {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    }
    xmlhttp.onreadystatechange handler;
    return 
    xmlhttp;
    }
    function 
    myHandler() {
    if (
    myRequest.readyState == && myRequest.status == 200) {
    e.innerHTML myRequest.responseText;
    }
    }
    function 
    pagexmlric(utente,testo){
    myRequest CreateXmlHttpReq(myHandler);
    document.getElementById("xmlric");
    myRequest.open("GET","page/insric.php?utente="+utente+"&testo="+testo);
    myRequest.send(null);

    Prendo da un'altra funzione i dati da 2 campi di testo li invio alla funzione della richiesta che a sua volta li invia ad una pagina php ma questo invio di dati vendono fatto col metodo get, come posso modificarlo per inviarli in metodo post????

  2. #2
    scusate il titolo ho sbagliato a scrivere volevo dire richiesta AJAX httprequest

  3. #3
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  4. #4
    bene garzie cavicchiaandrea mi smebra di aver capito quindi dovrei modifire cos' la funzione:

    Codice PHP:
    function pagexmlric(utente,testo){
    myRequest CreateXmlHttpReq(myHandler);
    document.getElementById("xmlric");
    myRequest.open("POST","page/insric.php");
    muRequest.setRequestHeader("content-type""application/x-www-form-urlencoded");
    myRequest.send("utente?"+utente+"&testp="+testo);

    /* e da come letto con posto dovrei chiudere la connessione
    o lo dovrei fare anche col metoto GET?*/
    myRequest.setRequestHeader("connection""close"); 

  5. #5
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    togli questa riga myRequest.setRequestHeader("connection", "close"); che se non ricordo male "scombussola" ie.
    Attenzione hai scritto nel send testp al posto di testo.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  6. #6
    ecco ho fatto questo per inviare col metodo post:

    codice html:
    Codice PHP:
    <label>
    <
    input name="utente" type="text" class="txtseach" id="utente" size="50" maxlength="250">
    </
    label>
    <
    label>
    <
    textarea name="testo" cols="62" rows="7" class="textarearic" id="testo"></textarea>
    </
    label>
    <
    input name="button" type="button" class="BTseach" id="button" value="Inserisci commento" style="cursor:pointer" onClick="if(document.getElementById('utente').value!='' && document.getElementById('testo').value!='') pagexmliscomm(document.getElementById('utente').value,document.getElementById('testo').value)"
    codice ajax:
    Codice PHP:
    function pagexmliscomm(idc,utente,testo){
    myRequest CreateXmlHttpReq(myHandler);
    document.getElementById("commcover");
    myRequest.open("POST","inc/inscomm.php");
    muRequest.setRequestHeader("content-type""application/x-www-form-urlencoded"); 
    myRequest.send("idc="+idc+"&utente="+utente+"&testo="+testo);

    ecco non funge come mai???

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.