JQuery POST无法处理错误

时间:2021-07-20 20:39:07

When I try to post using JQuery, I get this error:
jquery.min.js:4 POST http://localhost:8000/post,json 501 (Unsupported method ('POST'))

当我尝试使用JQuery发布时,我收到此错误:jquery.min.js:4 POST http:// localhost:8000 / post,json 501(不支持的方法('POST'))

Here's my code:

这是我的代码:

<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"</script>
    </head>
    <body>
        <script>
            $.ajax({
                type: "post",
                dataType: "json",
                url: "./post,json",
                success: function(data) {
                    alert(data.msg);
                }, data: {
                    name: "chris",
                    grade: 11
                }
            });
        </script>
    </body>
</html>

What am I doing wrong?

我究竟做错了什么?

1 个解决方案

#1


2  

Maybe it's problem with your URL? "./post,json" it looks strange. Also you can't use coma in url, or you must quote it.

也许你的网址有问题? “./ post,json”看起来很奇怪。你也不能在网址中使用昏迷,或者你必须引用它。


Also you can try to change data

您也可以尝试更改数据

data: JSON.stringify({
    name: "chris",
    grade: 11
})

#1


2  

Maybe it's problem with your URL? "./post,json" it looks strange. Also you can't use coma in url, or you must quote it.

也许你的网址有问题? “./ post,json”看起来很奇怪。你也不能在网址中使用昏迷,或者你必须引用它。


Also you can try to change data

您也可以尝试更改数据

data: JSON.stringify({
    name: "chris",
    grade: 11
})