我正在编写我的第一个基于HTML5的应用程序,我也在编写我的第一个Web服务并尝试两者之间的内部连接。也便于试验台为了这个,我已经建立了简单的本地.vb
基于Web的服务,这是如下:挣扎从jQuery调用返回数据到vb.Net asmx web服务
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Verify
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
<System.Web.Services.WebMethod()> _
Public Function UsernameVerify(ByVal username As String) _
As Boolean
Return (username = "Username")
End Function
<System.Web.Services.WebMethod()> _
Public Function PasswordVerify(ByVal pass As String) _
As Boolean
Return (pass = "RandomPassword123")
End Function
End Class
我想测试我的应用程序能够连接到Web服务,发送数据,并收到适当的回报。要做到这一点我用jQuery的:
function verifyInfo(){
$.ajax(
{
Type: 'Post',
url: 'http://localhost/TestWebService/Verify.asmx/HelloWorld',
success: function(data){alert(data);},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger;
}
});
}
现在的问题是,在存储数据的值将输出为[object Document]
,我不能完全肯定从这里到继续。从调用HelloWorld函数调用,我希望返回一个字符串Hello World
。当我在Visual Studio中通过调试做一个基于浏览器的测试所调用做工精细,并返回相应的XML输出,如:
<string xmlns="http://tempuri.org/">Hello World</string>
对不起,这么长的文章,但希望能得到关于如何获得一些指导期望的数据在POST服务之后返回作为回报。
非常感谢您提供任何提示/提示/建议。
我有一种感觉的一部分issu e是我的webservices POST'Content-Type:application/x-www-form-urlencoded'这可能是导致我的问题的一部分,因为它不是json对象? – JDD