Jump to content

Working with AJAX


Obi1-Cannabis

Recommended Posts

i'am trying just a simple test to see how to work with AJAXthis is my code:HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml">	<head>		<script src="login.js"></script>	</head><body><table width='250'>	<tr><td align='right'>	<fieldset>		<legend>			Detect		</legend>			<form action='post'>			<p>				NAME:				<input type='text' name='ident' id='ident' onblur="checkid()"/>  			</p>			<p>				JOB:				<input type='text' name='pass' id='pass'/>  			</p>		</form>	</fieldset>	</td></tr></table></body></html>

JScript

var url = "getPass?id="; // The server-side scriptfunction handleHttpResponse() {  if (http.readyState == 4) {	document.getElementById('pass').value = results;  }}function checkid(){  var id = document.getElementById("ident").value;  http.open("GET", url + escape(id), true);  http.onreadystatechange = handleHttpResponse;  http.send(null);}function getHTTPObject() {  var xmlhttp;  @cc_on  @if (@_jscript_version >= 5)	try {	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");	} catch (e) {	  try {		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");	  } catch (E) {		xmlhttp = false;	  }	}  @else  xmlhttp = false;  @end @  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {	try {	  xmlhttp = new XMLHttpRequest();	} catch (e) {	  xmlhttp = false;	}  }  return xmlhttp;}var http = getHTTPObject();

PHP

<?php	echo "Painter"; ?>

but it gives an error on page saying i have an invalid character on line 33. i don't get it.

Link to comment
Share on other sites

i got it to work, the only problem now is that it returns all the php tags such as 'echo' and so on... in the example i gave before its returning

<?php echo "Painter"; ?>
inside the job field...this isn't suposed to happen right? so what can be wrong?
Link to comment
Share on other sites

Does the page render correctly when you type in the URL into your address bar rather than accessing it using AJAX? Try visiting "getPass?id=someid", if it still shows the PHP code, then you don't seem to have your server configured correctly to handle PHP without the .php extension.

Link to comment
Share on other sites

Does the page render correctly when you type in the URL into your address bar rather than accessing it using AJAX? Try visiting "getPass?id=someid", if it still shows the PHP code, then you don't seem to have your server configured correctly to handle PHP without the .php extension.
yes i guess you were correct, the problem was my server configuration, to think i almost hit my head against the table...thanks
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...