webmethod显示500(内部服务器错误)
webmethod shows 500 (Internal Server Error)
我正在尝试从alertBook.aspx.vb调用webmethod。但是每当我点击按钮时,我收到一个错误500(内部服务器错误)。
这是从javascript调用webmethod的正确方式吗?I am new to javascript.
提前感谢。
我的javascript如下:
function webMethod() {
setInterval(function () {
$.ajax({
type: "post",
url: "alertBook.aspx/newUid",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
OnSuccess(result);
},
error: function (xhr, status, error) {
OnFailure(error);
}
});
}, 3000);
}
function OnSucceeded(response) {
alert(response);
//pushNoti(response, "info", "y");
}
function OnFailure(error) {
alert(error);
}
alertBook。aspx是
<a class="btn btn-info" onclick="webMethod()">WebMethod</a>
我的webmethod如下:
<WebMethod()> _
Public Shared Function newUid(ByVal msg As String) As String
Dim objForm As New alertBook
Dim objUtl As New uClass.fUtilities
Dim sqlQuery As String
Dim UID1, UID2 As String
Dim notiStr As String
Dim objDb As New uClass.dbFunctions("myCon")
Dim dtRecords As DataTable
sqlQuery = "select top 1 UID from alertsBook order by UID desc"
If objDb.getDataTable(dtRecords, sqlQuery) = False Then
Return objForm.displayMessage("Error", objDb.errDesc)
End If
For rCount = 0 To dtRecords.Rows.Count - 1
UID1 = dtRecords.Rows(rCount)("UID")
Next
If UID1 <> UID2 Then
notiStr = "<script> " & displayNoti("", "info", "New Message", True) & "</script>"
UID2 = UID1
'scriptDiv.InnerHtml = notiStr
Else
notiStr = ""
End If
Return notiStr
End Function
您应该查找有关错误的更多细节。你可以使用
error: function (xhr, status, error){
alert(xhr.status);
alert(xhr.responseText);
}
xhr.responseText
包含ajax-error的详细信息。
获取更多的错误细节,并相应地修改代码。
相关文章:
- SignalR:调用集线器方法时出现内部服务器错误
- 如何解决“;错误所请求的URL返回500-内部服务器错误”;
- 使用javascript API响应内部服务器错误将曲目上传到SoundCloud
- AJAX错误状态代码500内部服务器错误
- Python在尝试保存新的JSON文件时导致服务器错误
- Jcrop&画布:裁剪区域的大小很奇怪;500内部服务器错误
- 如果JS会话变量为null,如何避免500内部服务器错误
- 如何在getJSON中捕获服务器错误
- POST encodeURI查询字符串内部服务器错误 500
- getJSON:网络错误:500 内部服务器错误
- 如何捕获服务器错误 JS
- Node.js:Mongoose内部服务器错误
- 缺少用于创建的模板.内部服务器错误-聚合物表单保存到数据库
- Jquery AJAX Post:500(内部服务器错误)
- 我的联系表格在测试/PHPMailer后给了我一个内部服务器错误(500)
- 服务器错误消息的正确正则表达式
- 500(内部服务器错误)的外部php文件
- 当显示找不到服务器错误页面时,如何刷新页面/框架
- 如何使用ng-messages在Angularjs中显示服务器错误
- 内部服务器错误在 post 请求中使用 Angular js 中的自定义服务