ajax - Put jquery with django rest api -
i trying update data via ajax jquery.
when use api update data works correctly. when try use ajax put not update.
$.ajax({ type: 'put', url: "/api/attend/" + this.props.id + ".json", headers: { 'authorization': "token " + token }, data: json.stringify({attend_ts: '2016-07-05t13:44:21.855910z'}), success: (result) => { console.log("success") }, error: function (cb) { cb } });
the data not update, jquery returns success @ console.
i found error, set datatype:
$.ajax({ type: 'put', url: "/api/attend/" + this.props.id + ".json", headers: { 'authorization': "token " + localstorage.token }, data: { report: 'test' }, datatype: "json", success: (result) => { console.log("success") }, error: function (cb) { cb } });
report field database
Comments
Post a Comment