在App.vue中
然后在需要使用这个方法的的vue组件中注入这个方法
// 使用jquery库// 客户端的脚本
function ajaxsave(id){
var url,data
url="server.asp"//这里是你的服务器文件
data={action:"isread",id:id}
$.post(url,data,function(result){
if(result=="1"){
document.getElementById('obj').value="已读"
}
else{
document.getElementById('obj').value="未查看"
}
})
}
//========下面是server.asp页面代码=============
dim action
action=request.form("action")
if action="isread" then
call DoRead()
end if
sub DoRead()
dim id
id=request.form("id")
// 这里添加你执行的代码
if true then // 已读
response.write("1")
else
response.write("-1")
end if
end sub
// 客户端的result就在你server.asp的respose.write的内容
同理,得证。AJAX这东东就能行。例如哈。下面是代码段,你有空研究哈子:超级简单<textarea cols="60" name="msgcontent" rows="5" class="ipt-txt" id="msgcontent"></textarea>
昵称:<input type="text" name="username" id="username" size="10" class="ipt-txt" />
验证码:<input type="text" name="validate" size="4" class="ipt-txt" id="validdate" style="text-transform:uppercase"/><img src= "/include/verifycode.asp" id="validateimg" style="cursor:pointer" onclick="this.src=this.src+'?'" title="点击我更换图片" alt="点击我更换图片"
height="26" width="70"/>
<button type="button" onClick='PostComment()' value="" id="ok"></button>
其中
function PostComment() {
var xmlhttp
var tt
var msgContent,newsId,usrName,vCode
msgContent = document.getElementById('msgcontent').value
newsId = document.getElementById('news_fid').value//记录是对哪条新闻的评论
usrName = document.getElementById('username').value
vCode= document.getElementById('validdate').value
if (msgContent=="")
{
msg="总该写点什么吧O(∩_∩)O~"
alert(msg)
return false
}
if (msgContent.length <5 || msgContent.length >100)
{
msg="最少5个字符,最大不能超过100个字哦"
alert(msg)
return false
}
if (usrName=="")
{
msg="忘记填写昵称啦O(∩_∩)O~"
alert(msg)
return false
}
if (vCode=="")
{
msg="忘记填写验证码啦O(∩_∩)O~"
alert(msg)
return false
}
if(window.ActiveXObject) {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
}else if(window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest()
}
if (xmlhttp) {
xmlhttp.onreadystatechange=function() {
if(4==xmlhttp.readyState) {
if(200==xmlhttp.status) {
tt=xmlhttp.responseText
showmsg(tt)
}else {
alert("提交失败,网络连接错误.")
}
}
}
xmlhttp.open("get","/plus/?msg="+escape(msgContent)+"&nId="+escape(newsId)+"&uname="+escape(usrName)+"&vcode="+escape(vCode))
xmlhttp.send(null)
}
function showmsg(tmsg) {
if (tmsg==0) {
alert('验证码填写错误啦')
}else {
alert('评论成功')
}
}
}
plus目录下的ASP文件:
<%
dim msg,nId,uname,vcode
msg= trim(request.querystring("msg"))
nId=trim(request.querystring("nId"))
uname=trim(request.querystring("uname"))
vcode=trim(request.querystring("vcode"))
If CStr(Session("CheckCode"))<>CStr(vcode) Then
Call infoback("验证码错误!")
else
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from pinglun "
rs.Open sql,conn,1,3
rs.addnew
rs("pl_ID") = nId
rs("pinglun") = msg
rs("pinglun_nicheng") =uname
rs.update
rs.close:set rs=nothing
conn.close:set conn=nothing
end if
%>
就这样。回答完毕。很简单是吧。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)