I am facing a problem in Jquery ajax...
I want to pass a value in a function, this is my code:
$.each(data, function (index, value) {
id = value['req_id'];
notification.onclick = function () {
alert(id);return false;
$.ajax({
url : "<?php echo base_url(); ?>dashboard/notificationUpdated",
type : 'post',
data : {'id':id},
dataType: "json",
success : function(data){}
});
};
});
when id is alerted it shows "undefined". How to solve this ,i want to pass this value to controller.... Can anyone help me with this??? Waiting for a response........
data =>
{
"0":{
"req_id":"368"
},
"1":{
"req_id":"371"
},
"2":{
"req_id":"372"
},
"3":{
"req_id":"373"
},
"4":{
"req_id":"375"
},
"5":{
"req_id":"376"
},
"6":{
"req_id":"378"
},
"7":{
"req_id":"379"
},
"8":{
"req_id":"380"
},
"9":{
"req_id":"382"
},
"10":{
"req_id":"385"
},
"11":{
"req_id":"386"
},
"12":{
"req_id":"387"
},
"13":{
"req_id":"399"
},
"14":{
"req_id":"400"
},
"15":{
"req_id":"404"
},
"16":{
"req_id":"405"
},
"17":{
"req_id":"406"
},
"18":{
"req_id":"418"
},
"19":{
"req_id":"419"
},
"20":{
"req_id":"422"
},
"21":{
"req_id":"424"
},
"22":{
"req_id":"425"
},
"23":{
"req_id":"428"
},
"24":{
"req_id":"429"
},
"25":{
"req_id":"430"
},
"26":{
"req_id":"431"
},
"27":{
"req_id":"432"
},
"28":{
"req_id":"434"
},
"status":"success"
}
put console.log(value)to show what it returned