Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-23-2012, 05:25 PM   PM User | #1
flyingelephant
New to the CF scene

 
Join Date: Jul 2012
Location: Canada :)
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
flyingelephant is an unknown quantity at this point
AJAX not working...

Hello people, I'm currently working on a website, building a booking system.

So...somehow my AJAX is not working and got me question mark =(

Below is the code.

In homepage.php:

<script type='text/javascript'>

function change(ro,cc)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","adminupdate.php?q="+ro+"&w="+cc, true);
xmlhttp.send(null);
</script>

.
.
.
.
<tr>
<td>Table1</td>
<?php
$slotresult = mysql_query("select * from checkslot WHERE row='1' AND checkcol='1'"); //select all field from logintable and put into result
if(!$slotresult)
{
die("Database connection fail: " . mysql_error());
}
$row2 = mysql_fetch_array($slotresult);
if ($row2[status]==0)
{
?>
<td id="table11000" onclick="change(1,1)" style="background-color:greenyellow">
<?php

}
if ($row2[status]==1)
{
?>
<td id="table11000" onclick="change(1,1)" style="background-color:red">
<?php

}
if ($row2[status]==2)
{
?>
<td id="table11000" onclick="change(1,1)" style="background-color:blue">
<?php

}

?>
.
.
.

In adminupdate.php:

<?php
$connection = mysql_connect("localhost","root","123456") or die(mysql_error());
mysql_select_db('bookingdb',$connection);

$row=$_GET["q"];
$col=$_GET["w"];
$slotresult = mysql_query("UPDATE checkslot SET status='1' WHERE checkcol LIKE ('".$row."') AND row LIKE ('".$col."') ");
if(!$slotresult)
{
die("Database connection fail: " . mysql_error());
}
mysql_query($slotresult) or die(mysql_error());


?>

yeah, not sure where the error is, hope you guys can try your best to understand my program thanks for reading.
flyingelephant is offline   Reply With Quote
Old 07-23-2012, 05:53 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 946
Thanks: 7
Thanked 97 Times in 97 Posts
WolfShade is an unknown quantity at this point
Is it just not doing what you are expecting? Or does it display a message in the error console?
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 07-24-2012, 02:26 AM   PM User | #3
flyingelephant
New to the CF scene

 
Join Date: Jul 2012
Location: Canada :)
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
flyingelephant is an unknown quantity at this point
there is no output when onclick, database not updated too.
flyingelephant is offline   Reply With Quote
Old 07-24-2012, 01:35 PM   PM User | #4
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 946
Thanks: 7
Thanked 97 Times in 97 Posts
WolfShade is an unknown quantity at this point
One thing that I noticed from your code is that the <td>'s are not being closed, nor do I see any content. The AJaX appears correct, to me; at least I don't immediately see anything incorrect. If the database isn't updating, it's most likely in the PHP processing page "adminupdate.php".
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 07-26-2012, 04:08 AM   PM User | #5
flyingelephant
New to the CF scene

 
Join Date: Jul 2012
Location: Canada :)
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
flyingelephant is an unknown quantity at this point
i found the problem, my function change() did not have a close "}"
flyingelephant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:34 AM.


Advertisement
Log in to turn off these ads.