sql - update with jquery -


i making small site, can put in number in form field. number saved in mysql database, , value return in div id "show". have here made jquery number shown immediately, working fine.

i have made div tag id "showhot". here see numbers between 1 - 100 have been put in times. working fine sql string, jquery in not working. if update page, numbers moving , down, if specific number has been put in more times. have tried make jquery it, wrong.

is there has clue how that?
hope question understandable, otherwise reformulate it.

best regards mads

html:

<div id="show">     <div class="numberheader">         <p>tal</p>     </div>     <ul class="latestnumbers" style="list-style:none;padding-top: 60px;">         <?php include('response.php');?>     </ul>            </div>          <div class="content">     <p>number</p>     <div class="form">         <fieldset>             <legend>record number</legend>             <form id="myform" action="select.php" method="post">                 <input type="number" name="numbervalue" id="numberinput"/>                 <button id="sub">save</button>             </form>          </fieldset>     </div>     <span id="result"></span> </div>    <div id="#showhot">              <div class="hotnumbersheader">         <p>hot</p>     </div>       <ul class="hotnumbers" style="list-style:none; padding-top: 60px;">         <?php include('hotnumbers.php');?>     </ul> </div>   <div id="#showhot">          <div class="coldnumbersheader">         <p>cold</p>     </div>     <ul class="coldnumbers" style="list-style:none; padding-top: 60px;">         <?php include('coldnumbers.php');?>     </ul> </div> 

js:

// insert function number function clearinput() {     $("#myform :input").each( function() {          $(this).val('');     }); }      $(document).ready(function(){        $("#sub").click( function(e) {          e.preventdefault(); // remove default action(submitting form)         $.post( $("#myform").attr("action"),           $("#myform :input").serializearray(),           function(info){                      $("#result").html(info);        });        clearinput();     });     });  // recieve data database $(document).ready(function() {       setinterval(function () {         $('.latestnumbers').load('response.php')       }, 3000);     });    /* *** have been trying make, not working ****/ $(function ()    {    //send http request     $.ajax({                                             url: 'hotnumbers.php',           //the script call data                 data: "dbconfig.inc.php",        //url argumnets pass dbconnection       datatype: 'json',                //data format             success: function(data)          //on recieve of reply       {         var numbers = data[0];         //get numbers          // 3) update html content         $('#showhot').html("<b>number</b>"+numbers); //set output element html       }      });   });    // recieve data database $(document).ready(function() {       setinterval(function () {         $('hotnumbers').load('hotnumbers.php')       }, 3000);     }); 

hotnumbers.php

<?php include ('session.php'); include 'dbconfic.inc.php';      // '?' er placeholders variabler     $stmt = $mysqli->prepare("select numbers numbertable group numbers order count(*) desc limit 10;");      // execute prepared statement      $stmt->execute();      // make variables ready      $number = null;      $n_id = null;      // bind result variabler     $stmt->bind_result( $number);      // fetch values each row      while ($stmt->fetch()) {          echo "<li>".$number."</li>";      }        // close statement                           $stmt->close();      // close connection     $mysqli->close();          ?> 

you accidentally put pound sign in id of div in html: #showhot when should showhot. polling code missing period in selector: $('hotnumbers') instead of $('.hotnumbers'). looks have 2 divs same id of #showhot. meant 1 of them showcold. don't think that's causing problems yet, though.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -