I have some similar same logic in ajax but this one always get internal error 500 i already pass the token thanks in advance for those who help :)
$(document).ready(function(){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
token = $('meta[name="csrf-token"]').attr('content');
$(".edit-product").submit(function(s){
s.preventDefault()
$('.modal-backdrop').remove();
var recordID = $(this).data('recordid');
var product_id = $('#product_id_edit_'+recordID).val();
var product_name = $('#product_name_edit_'+recordID).val();
var product_link = $('#product_link_edit_'+recordID).val();
var product_category = $('#product_category_edit_'+recordID).val();
var product_subcategory = $('#product_subcategory_edit_'+recordID).val();
var product_price = $('#price_edit_'+recordID).val();
var product_price_sale = $('#price_sale_edit_'+recordID).val();
var tags = $('#selector_id_'+recordID).val();
var description = $('#product-edit-description_'+recordID).val();
$.ajax({
type: "POST",
url: "{!! url('advertiser/updateproduct') !!}",
data: {
_token: token, product_id: product_id, product_name: product_name, product_link: product_link,
product_category: product_category, product_subcategory: product_subcategory,
product_price: product_price, price_sale: product_price_sale, tags: tags, description: description
},
success: function(data) {
if(data.success == 1) {
$(".refresh-div").load("advertiser .refresh-div > *", function() {
$.getScript("js/jquery.js");
$('.tab_1').removeClass('active');
$('.tab_3').addClass('active');
$('#tab_default_3').addClass('active');
$('#tab_default_1').removeClass('active');
$('#flash_message').removeClass('flash_message').delay(10000).fadeOut();
$('#flash_message strong').after(' Product successfully edited')
return false;
})
}
else {
$(".refresh-div").load("advertiser .refresh-div > *", function() {
$.getScript("js/jquery.js");
$.getScript("js/ajax.js");
$('#error_message').removeClass('flash_message').delay(10000).fadeOut();
$.each(data.error, function (index ,errors) {
$('#error_message ul').append('<li>' + errors + '</li>')
})
});
}
}
, error: function(data){
// Error...
console.log(data);
}
});
});
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community