简体   繁体   English

在ajax调用上获取“不受支持的媒体类型415”-Jquery,ajax

[英]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.

相关问题 415不支持的媒体类型jQuery Ajax - 415 Unsupported Media Type jQuery Ajax 服务器响应的Ajax / JSON状态为415(不支持的媒体类型) - Ajax/JSON the server responded with a status of 415 (Unsupported Media Type) 尝试进行JSON调用时出现415(不支持的媒体类型)错误 - 415 (Unsupported Media Type) error while trying to make a JSON call 在 Spotify API 授权期间获取 HTTP 415 Unsupported Media Type - Getting HTTP 415 Unsupported Media Type during authorization in the Spotify API ASP AJAX POST调用返回不支持的媒体类型 - ASP AJAX POST call returns Unsupported Media Type 数据库连接在ajax调用中不起作用 - database connectivity not working in ajax call- laravel 415(不支持的媒体类型)错误 - 415 (Unsupported Media Type) Error AJAX POST引发415不支持的媒体类型错误,并显示消息“请求必须具有“ Content-Type:application / vnd.api + json”” - AJAX POST throws a 415 Unsupported Media Type Error with message 'Request must have “Content-Type:application/vnd.api+json”' 415 reactjs中不支持的媒体类型 - 415 Unsupported Media Type in reactjs 获取错误 415 - 获取 api 中不支持的媒体类型 - Getting error 415 - Unsupported media Type in fetch api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM