Hello, friends,
I faced the following error and I'm at a loss what to do with it.
I have PHP module in 2 files and JavaScript module. In PHP
part in File1.php I put some text to
$_GET['curimage']="img1.jpg";
and then read this text in File2.php
$curimage=$_GET['curimage'];
then I echo it
echo $curimage;
But on JavaScript part I receive EMPTY responseText ("").
And if in file2.php I don't read the text from $_GET, but assign it directly
$curimage="some text";
echo $curimage;
responseText is filled with "sometext" which is OK. What's the problem here ?
My code is below:
------------------------------------file1.php-----------------------------------------------
[CODE=php]<form action="#" method="get">
<input type="button" onclick="showTe xt()" id="btnTxt" value="Show text" />
<div id="item1"><?ph p require_once ("file2.php" ); $_GET['curval']='sometext';?></div>
</form>
<head>
<script language="javas cript" type="text/javascript">
var request = null;
function createRequest()
{
// I use Firefox on Linux Fedora8
request = new XMLHttpRequest( );
}
function printText()
{
if ( request.readySt ate == 4 && request.status == 200 )
{
alert(request.r esponseText);
}
}
function showText()
{
createRequest() ;
var url = "file2.php" ;
request.open("G ET", url, true);
request.onready statechange = printText;
request.send(nu ll);
}
</script>
</head>
[/CODE]
------------------------------------file2.php-----------------------------------------------
[CODE=php]<?php
$curval = $_GET['curval'];
echo $curval;
?>[/CODE]
PLEASE HELP !!!
THANK YOU!!!
I faced the following error and I'm at a loss what to do with it.
I have PHP module in 2 files and JavaScript module. In PHP
part in File1.php I put some text to
$_GET['curimage']="img1.jpg";
and then read this text in File2.php
$curimage=$_GET['curimage'];
then I echo it
echo $curimage;
But on JavaScript part I receive EMPTY responseText ("").
And if in file2.php I don't read the text from $_GET, but assign it directly
$curimage="some text";
echo $curimage;
responseText is filled with "sometext" which is OK. What's the problem here ?
My code is below:
------------------------------------file1.php-----------------------------------------------
[CODE=php]<form action="#" method="get">
<input type="button" onclick="showTe xt()" id="btnTxt" value="Show text" />
<div id="item1"><?ph p require_once ("file2.php" ); $_GET['curval']='sometext';?></div>
</form>
<head>
<script language="javas cript" type="text/javascript">
var request = null;
function createRequest()
{
// I use Firefox on Linux Fedora8
request = new XMLHttpRequest( );
}
function printText()
{
if ( request.readySt ate == 4 && request.status == 200 )
{
alert(request.r esponseText);
}
}
function showText()
{
createRequest() ;
var url = "file2.php" ;
request.open("G ET", url, true);
request.onready statechange = printText;
request.send(nu ll);
}
</script>
</head>
[/CODE]
------------------------------------file2.php-----------------------------------------------
[CODE=php]<?php
$curval = $_GET['curval'];
echo $curval;
?>[/CODE]
PLEASE HELP !!!
THANK YOU!!!
Comment