Jump to content

AJAX: PHP $_POST Params Not Received


Jesdisciple

Recommended Posts

I'm trying to get AJAX to work between my browser and localhost with the pretense that I need to keep some logic (i.e., for a bank script) confidential in a single-page app. Somewhere between

function getXmlHttpObject(){	var xmlHttp;	try{		// Firefox, Opera 8.0+, Safari		xmlHttp = new XMLHttpRequest();	}catch (e){		// Internet Explorer		try{			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");		}catch (e){			try{				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");			}catch(e){				alert("Your browser does not support AJAX!");				xmlHttp = null;			}		}	}	return xmlHttp;}function ClosedScript(url){	var _this = this;	var xmlHttp = getXmlHttpObject();	xmlHttp.onreadystatechange = function(ev){		switch(xmlHttp.readyState){			case 0:								break;			case 1:								break;			case 2:								break;			case 3:								break;			case 4:				_this.respond(xmlHttp.responseText);				break;		}	};	xmlHttp.open('POST', url, true);		this.request = function(query, responseFunc){		if(typeof(responseFunc) == 'function' && responseFunc.length == 1){			xmlHttp.setRequestHeader("Content-Length", query.length);			xmlHttp.send(query);			this.respond = responseFunc;		}else{			throw 'IllegalArgumentException: \'responseFunc\' in \'request(query, responseFunc)\' must be a function which takes exactly one argument.';		}	};}ClosedScript.prototype = {	constructor: ClosedScript,		respond: null};

ClosedScript.php:

<?php	print_r($_REQUEST);	if(isset($_POST['content'])){		switch($_POST['content']){			case 'event':				if(isset($_POST['q'])){					switch($_POST['q']){						case 'load':							echo "eval:alert('onload detected at localhost')";							break;					}				}				break;		}	}?>

Any observations?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...