【发布时间】:2011-02-10 13:20:36
【问题描述】:
我正在尝试通过 AJAX 将 JSON 发布到经典 ASP 页面,该页面检索值、检查数据库并将 JSON 返回到原始页面。
我可以通过 AJAX 发布 JSON。我可以从 ASP 返回 JSON。我无法将发布的 JSON 检索到 ASP 变量中。
POST 使用 Request.Form,GET 使用 Request.Querystring。 JSON 有什么用?
我有 JSON 库,但它们只显示在 ASP 脚本中创建一个字符串然后对其进行解析。我需要在传递外部变量时解析 JSON。
Javascript
var thing = $(this).val();
$.ajax({
type: "POST",
url: '/ajax/check_username.asp',
data: "{'userName':'" + thing + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
async: false,
success: function() {
alert('success');
}
});
ASP 文件 (check_username.asp)
Response.ContentType = "application/json"
sEmail = request.form() -- THE PROBLEM
Set oRS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT SYSUserID FROM dbo.t_SYS_User WHERE Username='"&sEmail&"'"
oRS.Open SQL, oConn
if not oRS.EOF then
sStatus = (new JSON).toJSON("username", true, false)
else
sStatus = (new JSON).toJSON("username", false, false)
end if
response.write sStatus
【问题讨论】:
-
我没有答案,但我很同情你...经典的 asp 和 JSON 处理 - 听起来很有趣。
-
这很好奇...您确定 JSON 发出的不是 POST 或 GET 吗?!你试过用 Alex 的例子来验证吗?
-
@Paddy:经典的 ASP 仍然有助于为我的家人提供食物。就像 COBOL 一样,它还没有死。 ;-)
标签: jquery json asp-classic