I'm calling an ajax function to update a certain record and I'm getting a 415-Unsupported Media type. Below is the js:
$("#update").on("click", function(){
event.preventDefault();
return $.ajax('/update/record',{
method: 'PUT',
data:{
date: date
},
success: function(){
alert("record updated successfully");
}
});
html:
<form>
<button type="submit" id="update-cc">Update</button>
</form>
I don't know what I'm doing wrong here or what I need to add to get the correct form of the ajax call.Any ideas????
Thanks!
I believe you need to set the contentType and dataType in your ajax request
contentType: "application/json",
dataType: "json",
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.