php - POST data through AJAX and set as variable -


i not familiar javascript especialy when comes functions , ajax. trying data php page , have put div. when ever load page nothing comes up.

my ultimate goal data php or javascript first need figure out how / receive data.

here php code of feedupdate.php

    <?php require "dbc.php";      $function = $_post['function'];      switch($function)     case('initiate'):     $search="select * feedtest order id desc";     $request = mysql_query($search);     $mostrecent= mysql_fetch_array($request);     $mostrecentid = $mostrecent['id']     echo json_encode($mostrecentid);      break;        case('update'):     $search="select * feedtest order id desc";     $request = mysql_query($search);     $update= mysql_fetch_array($request);     $updateid = $update['id'];     echo json_encode($updateid);      break;           ?> 

here ajax

<div id="datacheck"></div>    <script>   $(document).ready(function()  {      $.ajax({           type: 'post'           url: 'feedupdate.php'           data: {'function': 'initiate',},           datatype: "json"           success: function(msg) {               $('#datacheck').html(msg);           }          });   }); // document ready 

there typo in ajax jquery code

success: fuction(msg) {...

it should spelled "function".this typo might problem , plus there should switch case

getstate

in php code.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -