I am fetching some json data using ajax call,and data is coming like ["2","Learn Python"]
,first field of this json data is id of result.
Problem is, I have to store this id in some other array and pass via url on some form submission.
Let me explain the scenario
initially user searches for result via search bar.
Results will appear and a checkbox associated with each result.
When user click on checkbox ajax call generated and it fetches related data to this result and show it in some hidden div's.
- now result coming in hidden div's after ajax call will be compared by user.
so I need to pass each fetched result id's using url
my ajax call code is
$(document).ready(function() {
$(".compare").change(function() {
if(this.checked) {
$('#compare_box').show();
var check = $(this).val();
$.ajax({
type: 'POST',
url: 'compare.php',
dataType : 'JSON',
data:{value : check},
success: function(data) {
console.log(data);
//var boxes[check] = [];
//boxes[check] = $(data);
id = [];
$('#result').append(data);
}
});
} else if (!this.checked && boxes[check]) {
boxes[check].remove();
delete boxes[check];
}
});
});