jquery真的是乙個非常優秀的js庫,簡單容易掌握,對於網頁中的多級選單、級聯效果、tab選項卡切換、輪轉顯示,實現起來都非常的簡單,往往就是幾句**的事。
做ajax應用,jquery提供的$.get()、$.post()函式都可以用於提交資料,但建議使用$.ajax()來提交,那兩個函式都不提供錯誤返回資訊,不利全面掌控。
看**實現,這裡我刪減了一部分,便於說明(comments.asp):
$(function());
function getcomments(pageno)
});}function addcomments()
});}}
提交資料是action代表要執行的操作,id傳遞文章id,page是請求的分頁頁面,math.round(math.random()*10000)防止頁面被瀏覽器快取而導致暫時無法重新整理,如果出錯顯示錯誤資訊
客戶端用escape()函式編碼含中文的字串,伺服器端用unescape()解碼,這樣做是為了防止亂碼,如果你採用的是utf8,那就不必了,設定正確的頁面編碼和服務端指令碼編碼就不會出問題。由於jquery預設使用utf8傳輸資料,而且不提供設定編碼,這裡只有自己做轉換,如果你用form外掛程式的時候就會發現,編碼問題是不能回絕的,看來以後得向utf8看起了,呵呵!
看以下處理**,長了點,不過就三個函式,乙個分支語句(proc_comments.asp):
<%
response.charset="gb2312"
dim action,id
action=lcase(trim(request("action")))
id=trim(request("id"))
select case action
case "getcomments"
dim pageno
pageno=trim(request.querystring("page"))
call getcomments(id,pageno)
case "addcomments"
addcomments(id)
case else
response.write "else"
end select
function iif(bexp1, sval1, sval2)
if (bexp1) then
iif = sval1
else
iif = sval2
end if
end function
function getcomments(id,page)
tempstr1="" & vbcrlf &_
"網友: 發表於 " & vbcrlf &_
"" & vbcrlf &_
"" & vbcrlf & "
" & vbcrlf
"dim rethtml
openconn(dbfile)
sqlstr="select * from comments where comm_pid=" & id & " order by comm_subdate desc"
'sqlstr="select * from comments"
call openrs(sqlstr,1)
dim rscnt:rscnt=rs.recordcount
dim pagesize:pagesize=3
dim pagenum
if (rscnt mod pagesize)=0 then
pagenum=rscnt/pagesize
else
pagenum=int(rscnt/pagesize)+1
end if
if not(rs.bof and rs.eof) then
dim swaphtml,cnt
rs.pagesize=3
rs.absolutepage=page
cnt=rs.pagesize
do while not rs.eof and cnt>0
cnt=cnt-1
swaphtml=tempstr1
swaphtml=replace(swaphtml,"",rs("comm_user"))
swaphtml=replace(swaphtml,"",rs("comm_subdate"))
swaphtml=replace(swaphtml,"",rs("comm_content"))
rethtml=rethtml & swaphtml
rs.movenext
loop
else
rethtml=tempstr2
end if
closers()
closeconn()
'顯示分頁相關資訊
if rscnt>0 then
pagehtml=replace(pagehtml,"",rscnt)
if pagenum>1 then
for i=1 to pagenum
linkhtml=linkhtml & iif(i=page,i & " ","" & i & " ")
next
else
linkhtml=""
end if
pagehtml=replace(pagehtml,"",linkhtml)
rethtml=rethtml & pagehtml
end if
response.write rethtml
end function
function addcomments(id)
openconn(dbfile)
sqlstr="insert into [comments](comm_user,comm_content,comm_pid) values('" &_
unescape(trim(request.form("comm_user"))) & "','" & unescape(trim(request.form("comm_content"))) & "'," & id & ")"
conn.execute(sqlstr)
closeconn()
end function
%>
硬體基礎 有刷 有感和無刷無感電機對比
有刷 有感和無刷無感電機的使用心得 工控老鬼 一 有刷馬達的原理 要講清這一問題,那就應粗略地了解一下有刷馬達的工作原理。接下來用乙個三電極 二磁極內轉子有刷馬達作為演示。二 無刷電機工作原理 首先,無刷電機不是直流電機,模型雖然是直流電池供電,但通過無刷電調之後就轉變為了三相交變電流傳輸到了三個極...
直流無刷減速電機
直流無刷減速電機引數 額定電壓 kv值 實際轉速 kv只 工作電壓 轉矩與轉速 最大電流和最大功率 三相六臂全橋驅動電路 6拍工作方式 需要知道第一步應該導通哪兩個mos管,所以需要知道轉子的位置資訊。霍爾感測器或者不使用感測器 配套電機霍爾感測器輸出值 在對 mos 管的控制有中兩個特殊情況需要注...
直流無刷風扇引腳說明
直流風扇根據引腳數量可分為三種 2pin,3pin,4pin 3pin 三個引腳分別為電源 接地和轉速計 輸出 3線風扇可通過改變dc電壓或者使用低頻pwm驅動訊號來控制。3線風扇有轉速計,可以顯示風扇轉速。使用者可通過讀取風扇轉速值調整風扇轉速。2線風扇 兩個引腳,分別為電源和地 可以通過改變dc...