我试图通过
AJAX将
JSON发布到经典ASP页面,该页面检索该值,检查数据库并将JSON返回到原始页面.
@H_301_2@我可以通过AJAX发布JSON.我可以从ASP返回JSON.我无法将发布的JSON检索到ASP变量中.
@H_301_2@POST你使用Request.Form,GET你使用Request.Querystring.我用什么JSON?
@H_301_2@我有JSON库,但它们只显示在ASP脚本中创建一个字符串,然后解析.我需要从传递外部变量时解析JSON.
@H_301_2@使用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'); } });@H_301_2@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