How to pass dropdown selected values(list) as a parameter via Ajax to controller
in js file :
var sid= document.getElementById('mySelect');
var setitem= "";
for(i=0;i<sid.options.length;i++){
setitem= setitem+ sid.options[i].value + ",";
}
// Remove the last splitter
setitem= setitem.substr(0,setitem.length-1);
alert(setitem);
Then pass the setitem to your data parameter in jQuery's AJAX.
data: {
list: setitem,
},
while send convert the object type
contentType: 'application/json; charset=utf-8',
data :JSON.parse(setitem) ; using parse method.
or
var sid= document.getElementById('mySelect');
var setitem= "";
for(i=0;i<sid.options.length;i++){
setitem= setitem+ sid.options[i].value + ",";
}
// Remove the last splitter
setitem= setitem.substr(0,setitem.length-1);
alert(setitem);
Then pass the setitem to your data parameter in jQuery's AJAX.
data: {
list: setitem,
},
while send convert the object type
contentType: 'application/json; charset=utf-8',
data :JSON.parse(setitem) ; using parse method.
or
use JSON.stringify(
setitem);
Note: while data sending and receiving we should take care what kind of deta we are sending and accorind to that we should take care and make sure that same data type is defined
Comments
Post a Comment