Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    problema con richieste xmlrequest

    Salve ho questo codive per inviare dati in background col metodo post

    codice html:
    <form name="formcomm" id="formcomm" method="post" action="inc/inscomm.php" onSubmit="pagexmlinscomm(); return false;">
    <input name="idc" type="hidden" value="<?php print $idc; ?>">
    <input name="utente" type="text" class="txtseach" id="utente" size="50" maxlength="250">
    <textarea name="testo" cols="62" rows="7" class="textarearic" id="testo"></textarea>
    <input name="button" type="submit" class="BTseach" id="button" value="Inserisci commento" style="cursorointer">
    coduce javascript:
    function pagexmlinscomm(){
    var idc=document.getElementById('idc').value;
    var utente=document.getElementById('utente').value;
    var testo=document.getElementById('testo').value;
    var stringa="idc="+idc+"&utente="+utente+"&testo="+tes to;
    myRequest = CreateXmlHttpReq(myHandler);
    e = document.getElementById("commcover");
    myRequest.open("POST","inc/pagcomm.php",true);
    muRequest.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    myRequest.send(stringa);
    }
    il problema sta nel fatto che cliccando sul pulsante mi si apre la pagina pagcomm.php senza effettuare la richiesta background.

  2. #2
    nessuno mi sa dire qualcosa a riguardo???

  3. #3
    Prova così (non testato)

    Codice PHP:
    <form name="formcomm" id="formcomm" >
    <input name="idc" type="hidden" value="<?php print $idc?>">

    <input name="utente" type="text" class="txtseach" id="utente" size="50" maxlength="250">

    <textarea name="testo" cols="62" rows="7" class="textarearic" id="testo"></textarea>

    <input name="button" type="button" class="BTseach" id="button" value="Inserisci commento" style="cursor:pointer" onclik="pagexmlinscomm();">
    "La vendetta è un piatto che va gustato freddo"
    Antico proverbio Klingon.
    Lo chiamavano il 'Computer Umano'. Sapeva contare fino a 20 e nudo fino a 21!

  4. #4
    scusa e cosa cambia così, i dati me li passa solo che invece di cericare la pagina che riceve i dati in background me la carica visibilmente cioè mi si apre la pagina che richiamo nel form con il print dei dati.

    Comunque le sto provando tutte provo anche la tua, ma poi col tuo metodo è inutile aprire un tag form visto che la chiamta della funzione viene fatta dal button.

  5. #5
    il fatto è che se lo passo col metodo GET mi funge benissimo e solo col metodo POST che non va.


    function pagexmlinscomm(){
    var idc=document.getElementById('idc').value;
    var utente=document.getElementById('utente').value;
    var testo=document.getElementById('testo').value;
    var stringa="idc="+idc+"&utente="+utente+"&testo="+tes to;
    myRequest = CreateXmlHttpReq(myHandler);
    e = document.getElementById("divcommcover");
    myRequest.open("POST","inc/inscomm.php");
    muRequest.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    myRequest.send(stringa);
    }

  6. #6
    ok mi dite il perchè con IE funge mentre con Firefox no vi posto il codice complteto:

    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 
    pagexmlinscomm(){
        var 
    idc=document.getElementById('idc').value;
        var 
    utente=document.getElementById('utente').value;
        var 
    testo=document.getElementById('testo').value;
    var 
    stringa="idc="+idc+"&utente="+utente+"&testo="+testo;
    myRequest CreateXmlHttpReq(myHandler);
    document.getElementById("divcommcover");
    myRequest.open("POST","inc/inscomm.php",false);
    myRequest.setRequestHeader("content-type""application/x-www-form-urlencoded");
    myRequest.send(stringa);

    questo e la parte html:
    Codice PHP:
    <div id="divcommcover"></div>
    <form name="formcomm" id="formcomm">
    <input name="idc" id="idc" type="hidden" value="<?php print $idc?>">
    <input name="utente" type="text" class="txtseach" id="utente" size="50" maxlength="250">
    <textarea name="testo" cols="62" rows="7" class="textarearic" id="testo"></textarea>
    <input name="button" type="button" class="BTseach" id="button" value="Inserisci commento" style="cursor:pointer" onClick="pagexmlinscomm()">
    </form>
    ripeto con IE funge mentre con firefox no per quale motivo???

  7. #7
    Be credo che mi debba arrendere visto che cho sbattuto e risbattuto la testa senza soluzione ed aiuto, mah... strano con IE funge con firefox no bahhhh

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.