asp.net - 为什么asp vb从ajax调用函数后面的代码返回404未找到
问题描述
我有一个 aspx 页面,我挣扎了好几个小时试图在输入事件的代码后面(vb)中调用一个函数。它不断返回 404 not found 错误,如下所示:
POST http://localhost:51976/simulations/agios.aspx/getbnqlibelle 404 (Not Found)
我的控制:
<asp:TextBox runat="server" ID="tcodebanque"
name="tcodebanque"
type="text"
class="form-control"
placeholder=""
style="width: 100px; float: left; margin-right: 5px; border: 1px solid #000;
font-size: 12px; padding: 5px; height: 25px; border-radius: 0px;"
onkeypress="getbnqlibelle(); return false;">
</asp:TextBox>
我的阿贾克斯:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<script type="text/javascript">
function getbnqlibelle() {
$.ajax({
type: "POST",
url: "agios.aspx/getbnqlibelle",
data: "{}",
dataType: "json",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
}
});
}
</script>
我背后的代码:
<System.Web.Services.WebMethod()>
Public Shared Function getbnqlibelle() As String
Return ("done")
End Function
我实际上已经尝试了互联网上的所有东西(每个解决方案),没有一个有效,你能帮我吗?
编辑:
尝试了不同的浏览器:同样的错误
解决方案
尝试更改 ajax 函数中的 URL 以包含“模拟”路径。
网址:“模拟/贴水.aspx/getbnqlibelle”
此外,使用浏览器的开发工具来准确验证请求的网络路径。
推荐阅读
- python - 如何使用python从POST请求中获取查询参数
- python - 如何删除我的 plyer 通知功能中的“Python”文本?
- mysql - 如何解决 ERROR 1452 使用 mysql 在表中添加外键
- gradle - 不能运行多个 LibGDX 游戏
- python - 获取每组最大值的索引
- firebase - 使用 Firebase 云功能将数据发布到 ElasticSearch,无需请求包模块
- firebase - 我可以使用在我的项目中被其他用户意外删除的 Firebase 应用 ID 吗?
- swift - 仍然无法弄清楚如何为用户删除订购异步任务
- git - 使用 .cpanel.yml 推送到 Github 存储库后自动更新 cpanel
- go - 签署 Coinbase 请求时签名无效,为什么?