<label>Group Name</label>
<select id="group" name="groupName">
<option value="0">Select Group Name</option>
<?php foreach ($userGroup as $item) { ?>
<option value="<?= $item->notificationGroupID ?>"><?= $item->groupName ?></option>
<?php } ?>
</select>
<br></br>
This is the dropdown which i am populating from database and when i select any option in the dropdown it fires the following ajax post
jQuery(document).ready(function(){
$("#group").change(function() {
var group_ids = {"grp_ids" : $('#group').val()};
$.ajax({
type: "POST",
data: group_ids,
url: "<?= base_url() ?>pushnotification_group_wise/group_wise_skyid",
success: function(data){
console.log(data);
}
});
});
});
now in the method "group_wise_skyid" inside a controller "pushnotification_group_wise" (as i am using codeigniter) the following codes are executing.
public function group_wise_skyid()
{
if(isset($_POST['grp_ids']))
{
$skyid['sky_id'] = json_encode($this->pushnotification_model->get_group_eblskyids($_POST['grp_ids']));
echo $skyid['sky_id'];
}
which is calling a model function and returning some data which i am echoing. Now in the success function of the ajax post when i do console.log(data) i get the following in the console
[{"mapID":"17","notificationGroupId":"3","eblskyId":"eblsky33"},{"mapID":"18","notificationGroupId":"3","eblskyId":"eblsky44"}]
which is in the json format. Now i need to access the data to be specific i need to access the
notificationGroupId
eblskyId
this two fields of the json string. Now should i store the whole json string in a variable then access somehow or how can i do that.
Thanks