I got the string from the ajax and passed the string in url as 1,2,3,4,5,6
After using explode function,
i.e. $explode_id = explode(',', $request->data);
I got the output as
["1","2","3","4","5","6"]
But I want the data as: [1,2,3,4,5,6]
How do I get it? And it should not be like ["1,2,3,4,5,6"] Because I want to compare the data in:
$product_id = Product::where('name', 'like','%'.$main.'%')->where('id', $explode_id)->pluck('id');
I got the answer here. Am passing the id that i want to match in URL like
$("input[type='checkbox']").click(function() {
if ($(this).is(':checked')) {
var days = $(this).val();
$.ajax({
type: "get",
url: '/getcreatedat',
data: { 'days': days },
success: successFunc,
error: errorFunc
});
function successFunc(data, status) {
var pageURL = $(location).attr("href");
window.location.href = pageURL+ '/' +data;
}
function errorFunc(xhr, error) {
console.log(error);
}
}
});
The next time I click the function: url passing the id's double the time