javascript - AJAX pass 2 variables into the php file -


<script> $(document).ready(function(){     var id = 1;     var name = "abu";      $.post("update.php", {id: id, name: name}, function(data)     {      }); }); </script> 

update.php

<?php     $id = $_post['id'];     $name = $_post['name'];      echo $id.'<br />';     echo $name.'<br />'; ?> 

from above code, want use jquery pass id , name js update.php update record. however, following error: undefined index .... doing wrong?

hii michael can set ajax post request this

  $.ajax({             type: 'post',             url: 'abc.php',             data: {box:id,keys:name},             success: function(msg) {              alert(msg);              }            }); 

then in php file can check isset if value set or not


Comments