pass value of select to ajax data
pass value of select to ajax data
Hello,
I don't know how to pass value to ajax data, can you help me please?
$(document).ready(function(){
var petsEditor=new $.fn.dataTable.Editor({
ajax:'controllers/pets.php',
table:'#pets',
fields:[
{label:'Breed:',name:'pets.idbreed',type:'select2',opts:{placeholder:'',allowClear:true}},
{label:'Sire:',name:'pets.idsire',type:'select2',opts:{placeholder:'',allowClear:true,
ajax:{
url:'controllers/sires.php',
dataType:'json',
data:function(params){
var qp={
idbreed: PETS.IDBREED <====== this is my problem
params:params._type,
};
return qp;
}
},
processResults:function(data){
return{
results:data
};
}
}},
thank you very much
Answers
Take a look at the examples in the
ajax.data
docs. You need to add properties to the parameter (which is the data being sent) you are passing into the function. There is no return statement.Kevin