下面图老师小编要向大家介绍下调用prototype.js的ajax进行post提交示例源码,看起来复杂实则是简单的,掌握好技巧就OK,喜欢就赶紧收藏起来吧!
【 tulaoshi.com - Web开发 】
以下是index.html:
%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"% 
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" 
html xmlns="http://www.w3.org/1999/xhtml" 
head 
meta http-equiv="Content-Type" content="text/html; charset=utf-8" / 
titlePROTOTYPE POST/title 
script language="javascript" type="text/javascript" src="/script/prototype.js"/script 
/head 
body 
script type="text/javascript" 
function postNewContact(){ 
var form = $(’form’); 
var name = $(’act’); 
var url = ’test2.asp’; 
var myAjax = new Ajax.Request(url,{method:’post’, 
parameters: Form.serialize(form), 
onComplete:showResponse}); 
} 
function showResponse(originalRequest){ 
alert(originalRequest.responseText); 
} 
/script 
form method="post" id="form" name="form" 
input type="text" name="act"  
input onclick="postNewContact();" name="pbut" type="button" value="POST" / 
/form 
/body 
/html 
以下是test2.asp:
%=request("act")% 
打开index.html后,在文本框输入字符,点击POST按钮,就可以看到提交后正确返回的效果.
来源:http://www.tulaoshi.com/n/20160219/1619099.html
看过《调用prototype.js的ajax进行post提交示例源码》的人还看了以下文章 更多>>