Jump to content

AJAX updating <div> with php file after executing another php file


Ronald245
 Share

Recommended Posts

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 by Ronald245
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.