Reputation: 477
I have JS code and I have little problem with that in my code, I have ridiculous problem but I can't find it please help me
it's my Error:
Uncaught ReferenceError: lD0MnvK211576600138 is not defined at HTMLAnchorElement.onclick
my code is = lD0MnvK211576600138
<li><a onclick="recived( {{$item->code}} )">done</a></li>
js:
<script>
function recived(code) {
console.log(code);
$.ajax({
type: "post",
url: '/incomingCargo',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data: {
'code':code
}, // serializes the form's elements.
success: function(data)
{
console.log('g')
}
});
}
</script>
Upvotes: 0
Views: 118
Reputation:
I think you need to surround {{$item->code}}
in single quotes. You're inserting a string into your JS code, but strings need to be enclosed in quotes:
↓ ↓
recived('{{$item->code}}')
Upvotes: 3