[英]Getting an “Unsupported media type-415” on an ajax call- Jquery,ajax
I'm calling an ajax function to update a certain record and I'm getting a 415-Unsupported Media type. 我正在调用ajax函数来更新某些记录,并且得到415不支持的媒体类型。 Below is the js:
以下是js:
$("#update").on("click", function(){
event.preventDefault();
return $.ajax('/update/record',{
method: 'PUT',
data:{
date: date
},
success: function(){
alert("record updated successfully");
}
});
html: 的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???? 我不知道我在这里做错了什么,或者我需要添加什么才能获得正确形式的ajax调用。
Thanks! 谢谢!
I believe you need to set the contentType and dataType in your ajax request 我相信您需要在ajax请求中设置contentType和dataType
contentType: "application/json",
dataType: "json",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.