Currently I'm pass one value from ajax to php using onlick event.this is my onclick
<a href="#" id="<?php echo $row['cat_id'];?>" onclick="showCat(this.id)" >click </a>
and this is my ajax code
function showCat(id) {
//get the selected value
//make the ajax call
$.ajax({
url: 'ajax_categ.php',
type: 'GET',
data: {option : id},
success: function(data) {
document.getElementById('meal').innerHTML =data;
}
});
}
what i want to do is,i want to pass another value from ajax code. this is i want to pass value
<input type="text" value="<?php echo $resname;?>" name="another" />
You can get text box value using $("input[name='another']").val()
and it can be passed to ajax call parameter which is mentioned in code.
function showCat(id) {
var resname = $("input[name='another']").val(); //here you can getvalue of your textbox
//make the ajax call
$.ajax({
url: 'ajax_categ.php',
type: 'GET',
data: {option : id, resname : resname},
success: function(data) {
document.getElementById('meal').innerHTML =data;
}
});
}
Edit your function so it accepts two parameters:
<a href="#" id="<?php echo $row['cat_id'];?>" onclick="showCat(this.id, '<?php echo $resname;?>')" >click </a>
function showCat(id, resname) {
//get the selected value
//make the ajax call
$.ajax({
url: 'ajax_categ.php',
type: 'GET',
data: {option : id, resname: resname},
success: function(data) {
document.getElementById('meal').innerHTML =data;
}
});
}
1. pass two argument in all_task()
onclick="all_task('<?=$all?>','<?=$project_id?>');"
2. then in Ajax file:
function all_task(val,project_id){
if(val!=''){
$.ajax({
type:"post",
url:"ajax_alltask.php",
data: '&all_val='+val+'&project_id='+project_id,
dataType:"text",
success:function(response){
if(response!=''){
$('.modal-body').html(response);
}
}
});
}
}