ajax post problem

Discussion in 'JavaScript' started by gilgalbiblewheel, Oct 30, 2008.

  1. #1
    When it comes to the POST I don't know how to pass the parameters:
    function sendDelCheck(){		
    	var url = "delCheck.php";
    	/*these are supposed to be the paramters
    	tableName=game1
    	&CheckAll=Check+All
    	&selectVerse0=game1_1
    	&tableName=game2
    	&tableName=game3
    	&tableName=game4
    	&tableName=game5
    	&submit=Delete
    	*/
    	var params = "tableName="+document.getElementsByName('tableName').value+"&submit="+document.getElementById('deleteButton').value;
    	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);
    }
    Code (markup):

     
    gilgalbiblewheel, Oct 30, 2008 IP