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

    [Ajax] Problemi col POST di un modulo

    salve,
    ho qualche problema a far spedire un modulo col metodo POST per una chat Ajax.
    Dove sbaglio?

    codice:
    if(!window.XMLHttpRequest){
      var XMLHttpRequest = function(){
        try{ return new ActiveXObject("MSXML3.XMLHTTP")} catch(e) {}
        try{ return new ActiveXObject("MSXML2.XMLHTTP.3.0")} catch(e) {}
        try{ return new ActiveXObject("MSXML2.XMLHTTP")} catch(e) {}
        try{ return new ActiveXObject("Microsoft.XMLHTTP")} catch(e) {}
      }
    }
    
    var Http = new XMLHttpRequest();
    var wajax = 'http://www.nomesito.com/script/';
    
    
    function sendChat(){ 
    	var param = 'message=' + document.getElementById('txt_message').value+'&userid='+userid+'&chat=2';
    	Http.open("POST", wajax+"chat.php?chat="+room, true);
    
    	Http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    	Http.setRequestHeader("Content-length", param.length);
    	Http.setRequestHeader("Connection", "close");	
    	
    	Http.onreadystatechange = function(){			
    		if(Http.readyState == 4 && Http.status == 200){	
    			document.getElementById('txt_message').value = ''; 
    			document.getElementById('chat-text').innerHTML = Http.responseText; 
    		}
    	}
    	Http.send(param);
    }

    grazie mille in anticipo a chi vorrà aiutarmi,
    Una forte determinazione ad esser felici vi aiuterà

  2. #2
    mmm l'unica cosa che non mi convince è che non metti l'escape al testo che estrai dal element txt_message. Comunque, sei sicuro che room ed userid siano definite e valide?

    Se è così allora prova a togliere il wajax perché forse manda in palla la cosa, tanto lo devi fare sullo stesso sito, quindi non ti cambia niente.
    I DON'T Double Click!

  3. #3
    grazie mille !
    mica c'avevo pensato
    è bastato settare le variabili userid e room e funziona egregiamente
    Una forte determinazione ad esser felici vi aiuterà

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.