I am sending an ajax request to a php file as shown here:
function checkDB(code, userid)
{
$.ajax({
type: \"POST\",
url: \"
you should set your data
like so :
data: 'code='+code+'&userid='+userid
The answer from Linus Gustav Larsson Thiel refers, I used the following &.ajax() that triggers when a button is clicked and it works great. I could pass day, month and year parameters.
$('#convertbtn').on('click',function(){
ageddajax = $("#agedd").val();
agedmmajax = $("#agemm").val();
ageyyyyajax = $("#ageyyyy").val();
if(ageddajax > 0 && agemmajax > 0 && ageyyyyajax >0){
$.ajax({
type:'POST',
url:'ajaxDataAge.php',
data:'agedd_id='+ageddajax +'&agemm_id='+agemmajax +'&ageyyyy_id='+ageyyyyajax,
success:function(html){
$('#cydivage').html(html);
}
});
}
});
Here is how POST
data should be formatted:
key1=value1&key2=value2&key3=value3
In your case (note the &
as a separator):
'code=' + code + '&userid=' + userid
But jQuery does that for you if you specify your data as an object:
data: { code: code, userid: userid }
usually sending your data like this helps:
data: { code: code, userid: userid }
the most important thing to not forget is to verify if the name of the variables you are sending are the same in the server side
you can try this :
data: 'code='+code+'&userid='+userid,
instead of
data: 'code='+code+'userid='+userid,
Try this code...
<script>
function quote_ajax_table(){
var doc_name = '<?php echo $test; ?>';
var doc_no = '<?php echo $doc_no; ?>';
$.get('quote_ajax_table.php?doc_no='+doc_no+'&doc_name='+doc_name,function(data) {
$('.dyna').html(data);
});
}
</script>
//in html code
<div class="dyna"></div>