Jump to content

AJAX: PHP $_POST Params Not Received


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};


<?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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...