473,320 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

htmlrequest error ...

Hi,

This is my first time using the htmlrequest and I'm having a bit of
trouble.
I have a table that looks something like this
NAME STATUS
name1 ... ETK
name2 ... Recruiter
name3 ... ETK
name4 ... Recruiter

The status is a switch that I can press to toggle the value 'status' in
a database. If I press the ETK switch I want the database value changed
to 'ETK' or the equivalent, and the value of the status switch changed
to 'Recruiter' ... thereby pressing the thing again would change it's
value to Recruiter and change the switch back to 'ETK'

I can debug my javascript code no probs. I believe that my problem lies
in my php handler function. It doesn't seem to recognize my
$_GET['action'] variable.

This is a rough version of my php handler function

// get the value of the htmlrequest and call one of two functions based
on that value

if( isset( $_GET['action']) ){

ignore_user_abort();

switch ($_GET['action'])
{

case 'chsts':
change_status($_GET['name']);
exit ;
break;

case 'dete':
delete($_GET['name']);
exit ;
break;

default: exit ;

}

}

My problem is that I can't seem to find out what's going on in my php
code ... there is no page reload so var_dump or echo don't work. How
can I debug php code that is called from a htmlRequest function ?

This is the rest of my code in case you are interested ... this is my
first htmlrequest method.
I'm using a templating system to output my html, my switch looks
something like this.

<td><a
href="javascript:sndReq('chsts','{TEACHER.TEACHER_ NAME}');"
id='{TEACHER.TEACHER_NAME}'>[ETK]</a></td>

This just applies my sndReq function which sends off the htmlRequest in
this form

// send request function
function sndReq(action,name){

http.open('get', 'control_panel.php?action='+action+'&name='+name);
http.onreadystatechange = handleResponse;
http.send(null);
}

I took this code off the internet and made small changes, I believe
it's pretty basic
// build request object
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}

var http = createRequestObject();

This is my response handler ... I'm expecting php to send me back the
strings 'ETK' or 'Recruiter' I then wish to replace the status switch
for the relevant teacher

// handle my response, toggle the value of 'status' between 'ETK' and
'Recruiter'
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;

if(response.indexOf('|' != -1)) {
update = response.split('|');
alert(response);
document.getElementById(update[0]).innerHTML = update[1];
}

}
}

// this is where I change the status in the database, and then output
label the switch with the
// other value ... so that if I want to switch from ETK to Recruiter
.... I'll just have to hit the
// 'Recruiter' switch

function change_status($param)
{

// if I get the 'ETK' value, set status to 0 and set value of switch to
'Recruiter'

if($param=='ETK')
{
$sql_bit='UPDATE TEACHER SET status=0 WHERE name="$param"';

if(!($result=$db->sql_query($sql_bit)))
{
message_die(CRITICAL_ERROR, 'Error doing DB query update status',
'', __LINE__, __FILE__, $sql_bit) ;
}

echo "Recruiter";

}

// if I get the 'ETK' value, set status to 0 and set value of switch to
'Recruiter'

else if($param=='Recruiter')
{
$sql_bit='UPDATE TEACHER SET status=1 WHERE name="$param"';
if(!($result=$db->sql_query($sql_bit)))
{
message_die(CRITICAL_ERROR, 'Error doing DB query update status',
'', __LINE__, __FILE__, $sql_bit) ;
}

echo "ETK";
}
else{
return ;
}

}

Mar 26 '06 #1
1 1762
da*********@gmail.com wrote:

My problem is that I can't seem to find out what's going on in my php
code ... there is no page reload so var_dump or echo don't work. How
can I debug php code that is called from a htmlRequest function ?

Add some unit tests and run it from the command line.

--
Ian Collins.
Mar 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.