我使用jquery附加数据,但不在laravel中处理此数据的任何事件
我使用的是laravel 5.6 我使用bellow事件并附加我使用jquery附加数据,但不在laravel中处理此数据的任何事件,jquery,ajax,laravel-5,Jquery,Ajax,Laravel 5,我使用的是laravel 5.6 我使用bellow事件并附加div.categoryAjaxId 此代码正在运行并附加我的代码 //--------- get product ------------------------- jQuery('.orderProduct').click(function(e){ var productId = $(this).attr('id'); var token = '{{ csrf_token() }}'; e.prevent
div.categoryAjaxId
此代码正在运行并附加我的代码
//--------- get product -------------------------
jQuery('.orderProduct').click(function(e){
var productId = $(this).attr('id');
var token = '{{ csrf_token() }}';
e.preventDefault();
jQuery.ajax({
url: "{{ url('order/getCategoryAjax') }}",
method: 'post',
data: {
id: productId,
_token: token
},
success: function(data){
$('#orderProductSelect').hide();
$('.categoryAjax').show();
$.each(data, function(index,category){
$('.categoryAjax').append('<div class="col-md-4 categoryAjaxId" id="'+category.id+'" style="margin: 10px;cursor: pointer;">' +
'<img style="width: 100%;" src="/images/'+category.filename+'">' +
'<span>'+category.name+'</span>' +
'</div>');
});
}});
});
但这一事件并不奏效。并且在控制台.log中不显示任何内容
谢谢你的帮助你已经试过点击了吗
//----- get feature and value of category --------------------
jQuery('.categoryAjaxId').on('click',function(e){
var categoryId = $(this).attr('id');
//console.log(categoryId);
var token = '{{ csrf_token() }}';
e.preventDefault();
jQuery.ajax({
url: "{{ url('order/getFeatureAjax') }}",
method: 'post',
data: {
id: categoryId,
_token: token
},
success: function(data) {
$('.categoryAjaxId').hide();
$('.featureAjax').show();
$('.featureAjax').append('xxxxxxxxxxx');
}
});
});
是因为console.log被注释掉了吗?谢谢。不给你的评论谢谢。我测试你的代码。但不起作用。没有任何errortanks,$(document).on(“单击”,$(选择器),function(){//Your code here});是的,你完全正确!我有点快,我会编辑答案:)
//----- get feature and value of category --------------------
jQuery('.categoryAjaxId').on('click',function(e){
var categoryId = $(this).attr('id');
//console.log(categoryId);
var token = '{{ csrf_token() }}';
e.preventDefault();
jQuery.ajax({
url: "{{ url('order/getFeatureAjax') }}",
method: 'post',
data: {
id: categoryId,
_token: token
},
success: function(data) {
$('.categoryAjaxId').hide();
$('.featureAjax').show();
$('.featureAjax').append('xxxxxxxxxxx');
}
});
});