Reputation:
I am using ajax with laravel and when I clicked save button. I am getting this error in Console:
TypeError: $.POST is not a function
This is piece of code:
$('form').submit(function (event) {
event.preventDefault();
name = $('#name').val();
address = $('#address').val();
country = $('#country').val();
$.POST("{{ route('peoples.store') }}", {name:name, address:address, country:country}, function (data) {
$('#name').val('');
$('#address').val('');
$('#country').val('');
console.log(data);
var tr = "<tr>"+
"<td>"+data.id+"</td>"+
"<td id='ename'>"+data.data.name+"</td>"+
"<td id='eaddress'>"+data.data.address+"</td>"+
"<td id='ecountry'>"+data.data.country+"</td>"+
"<td>"+
"<button class='btn btn-warning' id='edit' data-id="+data.id+">Edit</button>"+
"<button class='btn btn-danger'>Delete</button>"+
"</td>"+
"</tr>";
$('#data').append(tr);
});
});
Upvotes: 2
Views: 3900
Reputation: 2448
I'm assuming that you are using JQuery? If so, then the correct method is:
$.post();
JavaScript is case sensitive.
Upvotes: 2
Reputation: 68
I think You are using the slim version of jQuery, which doesn't have AJAX $.post function, can you try that:
https://code.jquery.com/jquery-3.1.0.min.js
Upvotes: 2