我使用ajax选择表单的select字段。
$('#importers_tag').ajaxChosen(
{
dataType : 'json',
type : 'POST',
url : site_url + '/dashboard/load_products'
},
{
generateUrl : function(q) {
return site_url + '/dashboard/load_products/'
+ encodeURIComponent($('#importers_tag').val()) //dynamic url to avoid duplicate in result
},
loadingImg : baseUrl
+ '/resources/js/plugins/chosen/loading.gif'
});
我在ajax请求中的查询是通过以下查询
$query = $this->db->query('select * from product where product_id not in ('.$not_in.') and product_name like "%'.$q.'%"');
但是ajax选择的选择选项产生“product_name like'$ q%'”
我想通过外卡双方给出选择结果。
答案 0 :(得分:0)
尝试相反,您可以查看http://api.jquery.com/serialize/并使用 jQuery ajax并使用序列化发送表单数据,在后端方面,您可以处理这些参数并进行干净的查询,而不是随意使用结果。