[SOLVED ]Ajax Test
Posted: Wed Jul 04, 2007 2:36 am
feyd | Please use
chechSession.php[/syntax]
ajaxTest.php
If I want to return some thing from chechSession.php and want to display the returned value on the ajaxTest.php please show me how can I do it.
thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
Its me trouble again
This is code I am using for testing:
script.js
[syntax="javascript"]
function getQuery()
{
var xmlHttp=null;
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 and this page will not function correctly.");
return;
}
}
}
if (xmlHttp===null) {
alert ("Your browser does not support AJAX and this page will not function correctly.");
return;
}
xmlHttp.overrideMimeType("text/html");
var url="http://localhost/checkSession.php";
xmlHttp.open('GET',url,true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange=function() {
if (xmlHttp.readyState==4) {
document.getElementById("txtHere").innerHTML=xmlHttp.responseText;
}
}
xmlHttp.send(null);
}
Code: Select all
<?php
session_start();
$_SESSION['item'] = "CKone";
?>Code: Select all
<?php
session_start();
$_SESSION['item'] = "D&G";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>AJAX Fun!</title>
<script type="text/javascript" src="script.js" />
</head>
<body>
<p>AJAX Test...</p>
<p>Make a selection below to do things.</p>
<a href="javascript:getQuery()">Query 1</a>
<div id="txtHere">This will change when you select something</div>
</body>
</html>
<?php
echo "Now the session is";
echo $_SESSION['item'];
?>thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]