我正在尝试使用下面的代码将数据发布到http://requestb.in/。但是,我继续收到 HTTP/1.1 404 Not Found。我只是想在下面的代码中查看我的数据的 JSON 格式。
感谢您提供任何可能使我找到解决方案的想法。我正在使用 Fiddler 来定位我在第一段中提到的错误。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PostJSON.aspx.cs" Inherits="SimpleJSONPost.PostJSON" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#button1").click(function () {
$.ajax({
type: "POST",
url: "http://requestb.in/1g8nene1",
contentType: "application/json; charset=utf-8",
data: JSON.Stringify({"name": "John"}),
dataType: "json",
success: function (msg) { alert("Post Succeeded: " + msg) },
error: function (msg) { alert("Post Failed: " + msg) }
});
});
});
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="button1" runat="server" Text="PostJSON" />
</div>
</form>
</body>
</html>