【发布时间】:2014-03-07 06:13:32
【问题描述】:
我想调用写在我的VB页面中的webmethod。为此,我编写了以下代码。但是,它直接进入 error 块并显示消息 undefined。
JavaScript
function fnSaveReview(){
var content = new Object();
content.TableName = "BAChildProjects"
content.ColumnName = "cIsQCApproved"
content.ColumnValue = "Y"
content.Refcolumn = "vWorkSpaceId"
content.RefValue = $('#<%= HProjectId.ClientId%>').val();
var JsonString=JSON.stringify(content);
$.ajax({
type: "POST",
url: "frmBAProjectDefinition.aspx/UpdateFieldValues",
data: JsonString,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
alert('Data Reviewed Successfully.');
},
failure: function(error) {
alert(error);
},
error: function (data) {
debugger ;
alert(data.d);
}
});
}
VB.NET
<Web.Services.WebMethod()> _
Public Shared Function UpdateFieldValues(ByVal JSONString As String) As String
Dim objhelpDb As New WS_HelpDbTable.WS_HelpDbTable
Dim objLambda As New WS_Lambda.WS_Lambda
Dim eStr As String = String.Empty
Dim ds_Save As New DataSet
Try
ds_Save.Tables.Add(JsonConvert.DeserializeObject(JSONString, GetType(System.Data.DataTable)))
If Not objLambda.Save_UpdateFieldValues(WS_Lambda.DataObjOpenSaveModeEnum.DataObjOpenMode_Add, ds_Save, _
HttpContext.Current.Session(S_UserID), eStr) Then
Return False
Exit Function
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
Console.log(数据);
Object {readyState: 4, setRequestHeader: function, getAllResponseHeaders: function, getResponseHeader: function, overrideMimeType: function…}
abort: function (a){a=a||"abort",p&&p.abort(a),w(0,a);return this}
always: function (){return i.done.apply(i,arguments).fail.apply(i,arguments)}
complete: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
done: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
error: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
fail: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
getAllResponseHeaders: function (){return s===2?n:null}
getResponseHeader: function (a){var c;if(s===2){if(!o){o={};while(c=bJ.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c}
isRejected: function (){return!!e}
isResolved: function (){return!!e}
overrideMimeType: function (a){s||(d.mimeType=a);return this}
pipe: function (a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()}
progress: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
promise: function (a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a}
readyState: 4
responseText: "<html>
↵ <head>
↵ <title>The resource cannot be found.</title>
↵ <style>
↵ body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
↵ p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
↵ b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
↵ H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
↵ H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
↵ pre {font-family:"Lucida Console";font-size: .9em}
↵ .marker {font-weight: bold; color: black;text-decoration: none;}
↵ .version {color: gray;}
↵ .error {margin-bottom: 10px;}
↵ .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
↵ </style>
↵ </head>
↵
↵ <body bgcolor="white">
↵
↵ <span><H1>Server Error in '/BizNET' Application.<hr width=100% size=1 color=silver></H1>
↵
↵ <h2> <i>The resource cannot be found.</i> </h2></span>
↵
↵ <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
↵
↵ <b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
↵ <br><br>
↵
↵ <b> Requested URL: </b>/BizNET/frmBAProjectDefinition.aspx/UpdateFieldValues<br><br>
↵
↵ <hr width=100% size=1 color=silver>
↵
↵ <b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.5420; ASP.NET Version:2.0.50727.5459
↵
↵ </font>
↵
↵ </body>
↵</html>
↵<!--
↵[HttpException]: The file '/BizNET/frmBAProjectDefinition.aspx' does not exist.
↵ at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
↵ at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
↵ at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
↵ at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
↵ at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
↵ at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
↵ at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
↵ at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
↵ at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
↵-->"
setRequestHeader: function (a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this}
state: function (){return e}
status: 404
statusCode: function (a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this}
statusText: "Not Found"
success: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
then: function (a,b,c){i.done(a).fail(b).progress(c);return this}
__proto__: Object
undefined
我的主要问题是调试器甚至不去WebMethod 的VB.NET
【问题讨论】:
-
在错误回调中执行
console.log(data);并在此处发布.. -
请查看。我已经在
error块中发布了数据日志。 -
@iJay - error 中的警报消息显示消息 undefined
-
如果你看到你的日志,服务器没有响应。 "
“/BizNET”应用程序中的服务器错误。
找不到资源。
" 您调用了正确的文件或修复了 vb 页面中的错误 -
@Bala:如果你看到了,我在
JavaScript部分中调用了VB 页面的正确web method。甚至论据也是一样的。还需要什么更正?
标签: jquery json vb.net webmethod