This is My Code:
Title | URL |
Save
Results is array of objects returned from database.
const vm = new Vue({
el: '#app',
created: function()
{
this.loadData();
},
data: {
results: []
},
methods:{
loadData: function()
{
$.ajax({url: "/api/links", context:this , success: function(jres){
this.results = JSON.parse(jres);
}});
}
,
saveData: function()
{
$.ajax({
url: "/api/links",
method:"post" ,
data: JSON.stringify(this.results) ,
contentType: 'application/json',
dataType: 'json' ,
context:this ,
success:
function(res){
$("#res").html(res);
//alert(res);
}});
}
}
});
LoadData works fine. SaveData is triggered but not showing any results. It's supposed just to show me a "test string".
EDIT :
I removed dataType: 'json' and it shows me test string. But PHP $_POST array is empty.