I’m beginner on ajax with laravel. I want to post update with ajax. I implement ajax that works fine on local machine but when i upload on server it not working. I’m tired to solve this problem.
Hearder:
<meta name="csrf-token" content="{{ csrf_token() }}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
body:
<script type='text/javascript'>
var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
$(document).on("click", ".update42" , function() {
var edit_id = 42;
var name = 1 + 1;
$.ajax({
url: '/dashboard/post/42',
type: 'patch',
data: {_token: CSRF_TOKEN,id: edit_id,download_count: name},
success: function(response){
alert(response);
}
});
});
</script>
2
Answers
Just full address then solve
Add this to your script
then use it in your AJAX url