【发布时间】:2017-10-13 20:05:17
【问题描述】:
我从 ajax 得到字符串,并在 url 中将字符串传递为 1,2,3,4,5,6
使用爆炸功能后,
即$explode_id = explode(',', $request->data);
我得到的输出为
["1","2","3","4","5","6"]
但我希望数据为: [1,2,3,4,5,6]
我如何获得它? 它不应该像 ["1,2,3,4,5,6"] 因为我想比较中的数据:
$product_id = Product::where('name', 'like','%'.$main.'%')->where('id', $explode_id)->pluck('id');
我在这里得到了答案。 我正在传递我想在 URL 中匹配的 id,例如
$("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);
}
}
});
下次我点击该功能时: url 传递 id 的两倍时间
【问题讨论】:
-
你是在尝试
IN (1,2,3,4,5)吗? -
我正在使用 laravel。它不会工作
-
没有。这不起作用。
-
ya.. 这个答案已经给出。非常感谢