Ronald245 Posted January 8, 2016 Share Posted January 8, 2016 (edited) hi everyone, im new to these forums. as part of a project i'm working on i'm building a website for a large airline, i've had my ajax working perfectly but when i logged in on the site this morning it didnt update the <div> code on the page <div align="center"> <button class="buttonup" type="button" onclick="tempup()"></button> <script language="javascript"> function tempup() { $("#targettemp").load("targettemp.php"); $.ajax({ url: "tempup.php", //the page containing php script type: "POST", //request type }) $(document).ready(function () { $("#targettemp").load("targettemp.php"); }); } </script> <h4 class="target-temp panel-body" id="targettemp "> <?php require 'dbconnection.php'; $con; $dbcon; $temp = "SELECT `target temp` FROM Temperature WHERE homeid = 'BG0001' "; $query = mysql_query($temp); $results = mysql_result($query, 0); echo "$results ℃"; ?> </h4> <div align="center"> <button class="buttondown" type="button" onclick="tempdwn()"></button> <script language="javascript"> function tempdwn() { $("#targettemp").load("targettemp.php"); $.ajax({ url: "tempdwn.php", //the page containing php script type: "POST", //request type }) $(document).ready(function () { $("#targettemp").load("targettemp.php"); }); } </script> </div> </div> tempdwn.php <?php require 'dbconnection.php'; $con; $dbcon; $query = mysql_query("SELECT `target temp` FROM `Temperature` WHERE homeid = 'BG0001' "); $huidigetemp = mysql_result($query, 0); $newtemp = $huidigetemp - 1; mysql_query("UPDATE Temperature SET `target temp`= $newtemp WHERE homeid = 'BG0001' "); ?> targettemp.php: <?php require 'dbconnection.php'; $con; $dbcon; $temp = "SELECT `target temp` FROM Temperature WHERE homeid = 'BG0001' "; $query = mysql_query($temp); $results = mysql_result($query, 0); echo "$results ℃"; ?> Edited January 8, 2016 by Ronald245 Quote Link to comment https://forums.phpfreaks.com/topic/300222-ajax-updating-with-php-file-after-executing-another-php-file/ Share on other sites More sharing options...
codefossa Posted January 8, 2016 Share Posted January 8, 2016 Your ID for 'targettemp' has a space at the end causing your JS selector to fail. Quote Link to comment https://forums.phpfreaks.com/topic/300222-ajax-updating-with-php-file-after-executing-another-php-file/#findComment-1529289 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.