eval()用法 vb的数据以字符串传递给JS,如何处理(1)
2008-07-04 11:04
531 查看
index.asp
----------------------------------------------------------
<script src="ajax.js></script>
<form>
</ul>
<li>Q Q:<input type="text" maxlength="10" id="qq" /></li>
<li>性别:<input type="radio" name="sex" value="BOY" checked="checked"/>男<input type="radio" name="sex" value="GIRL"/>女<input type="radio" name="sex" value="NONE"/>保密</li>
<li>留言:<textarea id="content" cols="60" rows="10"></textarea></li>
<input type="button" onclick="sendJS();" value="保存" class="button" id="submit" />
</ul>
</form>
----------------------------------------------------------以上提交用sendJS()处理
ajax.js
function sendJS(){
xmlHttp = XMLHttpRequest();
var qq,sex,content,url;
qq = getVal("qq");
sex = getVal("sex");
content = getVal("content");
url="";
if(xmlHttp){
url ="save.asp?qq="+escape(qq)+"&sex="+escape(sex)+"&content="+escape(content);
xmlHttp.open("get",url,true);
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readystate==4){
if(xmlHttp.status==200){
if(xmlHttp.responseText=="1"){
alert("添加成功!");
}else if(xmlHttp.responseText=="0"){
alert("填写完整!")
}//1
}else{
alert("网络错误");
}//200
addMessage();
}//4
};//xmlhttp.onready
xmlHttp.send(null);
}//if xmlhttp
}//fun
function XMLHttpRequest(){
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttp != 'undefined')
xmlHttp = new XMLHttpRequest();
return xmlHttp;
}
数据的处理交给了save.asp
----------------------------------------------------------
<!--#include file="conn.asp"-->
<%
dim qq,sex,content
qq = request.QueryString("qq")
sex = request.QueryString("sex")
content = request.QueryString("content")
response.Write(content)
dim rs
set rs = server.createobject("adodb.recordset")
rs.Open "book",conn,3,3
if qq="" or content="" then
Response.Write("0")
else
rs.AddNew
rs("qq")=qq
rs("sex")=sex
rs("content")=content
rs.Update
rs.Close
set rs=nothing
Response.Write("1")
end if
%>
以上是保存到数据库,看下篇的读取数据库
----------------------------------------------------------
<script src="ajax.js></script>
<form>
</ul>
<li>Q Q:<input type="text" maxlength="10" id="qq" /></li>
<li>性别:<input type="radio" name="sex" value="BOY" checked="checked"/>男<input type="radio" name="sex" value="GIRL"/>女<input type="radio" name="sex" value="NONE"/>保密</li>
<li>留言:<textarea id="content" cols="60" rows="10"></textarea></li>
<input type="button" onclick="sendJS();" value="保存" class="button" id="submit" />
</ul>
</form>
----------------------------------------------------------以上提交用sendJS()处理
ajax.js
function sendJS(){
xmlHttp = XMLHttpRequest();
var qq,sex,content,url;
qq = getVal("qq");
sex = getVal("sex");
content = getVal("content");
url="";
if(xmlHttp){
url ="save.asp?qq="+escape(qq)+"&sex="+escape(sex)+"&content="+escape(content);
xmlHttp.open("get",url,true);
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readystate==4){
if(xmlHttp.status==200){
if(xmlHttp.responseText=="1"){
alert("添加成功!");
}else if(xmlHttp.responseText=="0"){
alert("填写完整!")
}//1
}else{
alert("网络错误");
}//200
addMessage();
}//4
};//xmlhttp.onready
xmlHttp.send(null);
}//if xmlhttp
}//fun
function XMLHttpRequest(){
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttp != 'undefined')
xmlHttp = new XMLHttpRequest();
return xmlHttp;
}
数据的处理交给了save.asp
----------------------------------------------------------
<!--#include file="conn.asp"-->
<%
dim qq,sex,content
qq = request.QueryString("qq")
sex = request.QueryString("sex")
content = request.QueryString("content")
response.Write(content)
dim rs
set rs = server.createobject("adodb.recordset")
rs.Open "book",conn,3,3
if qq="" or content="" then
Response.Write("0")
else
rs.AddNew
rs("qq")=qq
rs("sex")=sex
rs("content")=content
rs.Update
rs.Close
set rs=nothing
Response.Write("1")
end if
%>
以上是保存到数据库,看下篇的读取数据库
相关文章推荐
- eval()用法 vb的数据以字符串传递给JS,如何处理(2)
- HP1020打印机“传递给系统调用的数据区域太小” 如何处理?
- JS解析json数据(如何将json字符串转化为数组)
- 《项目经验》--通过js获取前台数据向一般处理程序传递Json数据,并解析Json数据,将前台传来的Json数据写入数据库表中
- Ajax 如何通过url 传递Json 数据或者数组 给PHP进行处理
- php和js如何通过json互相传递数据相关问题探讨
- js 将json字符串转换为json对象的方法解析 作者: 字体:[增加 减小] 类型:转载 将json字符串转换为json对象的方法。在数据传输过程中,json是以文本,即字符串的形式传递的,而J
- JS中eval处理JSON数据 为什么要加括号
- JS解析json数据(如何将json字符串转化为数组)
- js中eval函数对json格式数据的处理
- php和js如何通过json互相传递数据
- JS解析json数据(如何将json字符串转化为数组)
- js处理字符串的substr()slice()substring()match()replace()用法
- JS解析json数据(如何将json字符串转化为数组)
- 多视的情况下如何在视之间传递数据?MFC的做法是利用文档来处理
- 详解Node.Js如何处理post数据
- 《项目经验》--通过js获取前台数据向一般处理程序传递Json数据,并解析Json数据,将前台传来的Json数据写入数据库表中
- php和js如何通过json互相传递数据(转)
- JS解析json数据(如何将json字符串转化为数组)
- js如何把字符串转换成json数据的方法