Hi i tried to send a PUT request to my slim php api but it seems like that my parameters turns to null. here is my code:
function update() {
$.ajax({
type: 'PUT',
contentType: 'application/json',
url: 'api/edit' + '/' + $('#id').val(),
contentType: "application/json",
data: formToJSON(),
success: function(data, textStatus, jqXHR){
document.location.href="page.php?update=OK"
},
error: function(jqXHR, textStatus, errorThrown){
document.location.href="page.php?update=ERROR"
}
});
}
function formToJSON() {
alert($('#id').val()+' '+$('#param1').val()+' '+$('#param2').val()+' '+$('#param3').val());
return JSON.stringify({
"id": $('#id').val(),
"param1": $('#param1').val(),
"param2": $('#param2').val(),
"param3": $('#param3').val()
}
$('#btnUpdate').click(function() {
update();
return false;
});
Can someone help me out this? Please.