【发布时间】:2014-02-24 11:11:11
【问题描述】:
我正在尝试调用后台代码函数以将 json 返回到 jquery?
Public Function GetBushCampBooking() As string
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString = ConfigurationManager.ConnectionStrings("conn").ConnectionString
Dim dt As DataTable = New DataTable()
Dim ds As DataSet = New DataSet()
Dim cmd As New SqlClient.SqlCommand("BushCampBookingsGet", conn)
cmd.CommandType = CommandType.StoredProcedure
Try
conn.Open()
Dim Adp As SqlDataAdapter = New SqlDataAdapter(cmd)
Adp.Fill(ds)
Catch ex As Exception
Finally
conn.Close()
End Try
dt = ds.Tables(0)
Dim json As String
json = GetJson(dt)
Return json
End Function
jquery:
$.ajax({
type: "GET",
url: "BushCamp.aspx/GetBushCampBooking",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(result) {
alert(result.d);
//$("#content").html(result.d);
}
});
我的错误:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
http://localhost:10131/Hlh_shares/Content/BushCamp/BushCamp.aspx/GetBushCampBooking?{}
【问题讨论】:
-
内部服务器错误意味着 VB 脚本有问题。能否直接在服务器上运行(或单步执行)以便查看错误详情?
-
您不能调用直接页面函数,您必须创建 Web 服务,或者您必须使用 qurey 字符串调用页面并响应为 Json 格式字符串
标签: jquery ajax json vb.net get