javascript - Passing multiple parameters in AJAX script -
below script through trying send 2 parameters: 'badge' , 'srnum' name2.php.
$('input.accept').on('click',function(){ var badge= $(this).attr('id'); var srnum = $(this).attr('name'); //alert(badge+""+srnum); $.post('name2.php',{badge:badge,srnum:srnum},function(data){ $('td#status').text(data); }); });
name2.php -:
<?php $badge = $_post['badge']; $srnum = $_post['srnum'];; $connection = oci_connect("","",""); $main_query=oci_parse($connection,"update leaveinfo1 set lead='approved' badge='$badge' , srnum='$srnum'"); oci_execute($main_query); oci_close($connection); ?>
now, here not able post 2 variables using ajax script name2.php. how should post 2 or more variables , receive them in corresponding name2.php script.
you sending variables correctly, not accessing them in php correct way. can test doing var_dump($variable)
sure receiving data. since ajax request, var_dump
results show in network
tab of console
.
<?php $badge = $_post['badge']; $srnum = $_post['srnum']; $connection = oci_connect("","",""); $main_query=oci_parse($connection,"update leaveinfo1 set lead='approved' badge='".$badge."' , srnum='".$srnum."'"); oci_execute($main_query); oci_close($connection); ?>
be sure concatenating strings correctly, using ".$var."
, " or '
being starting quotation.
Comments
Post a Comment