我想 在JS中 传个参数到后台,然后得到返回值 改如何实现????急
解决方案 »
- 错误:当前上下文中不存在名称“SqlHelper”
- 请教高手一个SqlParameter[]问题
- ASP.NET 跳转页面无法显示
- 带有母版页的title设定
- 现在有很多网站流行用标签来定义,请问那标签是用什么原理?
- 百分在线求处理页面非法字符的问题。
- ASP.NET,分布式计算,网络服务(WEB SERVICES),网络应用编程这一大堆东西就竟有什么内在的联系?
- 求2个问题的思路,做过新闻系统的朋友来一下!
- 从dataset将数据导入excel中超过5行中文将出现乱码,这是为什么?
- 菜鸟一个,我按着书上写的,却报告说adoconnection没有定义,不知怎么弄!
- 使用.NET的文件上传
- try catch 包含代码段的问题
??
var s;
function Fuc()
{
var v = "";
startRequest(v);
alert(s);
}
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest(); } }
function startRequest(str) {
createXMLHttpRequest();
xmlHttp.onreadystatechange = handstateChane;
xmlHttp.open("Get", "AjaxInfo.aspx?str=" + str, true);
xmlHttp.send(null);
} function handstateChane() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
if (xmlHttp.responseText == "" || xmlHttp.responseText == "undefined") {
}
v = xmlHttp.responseText;
}
else {
alert("对不起!服务器端出错!"); }
}
}
</script>AjaxInfo.aspx.csprotected void Page_Load(object sender, EventArgs e)
{
if(Request["str"]!=null)
{
Response.Write(Request["str"].ToString()+"AAFGHHFGHF");
Response.End();
} }
后台代码加个引用,在load里注册下。
在方法前加上[AjaxMethod]
在js里就可以通过刚才注册的类访问了。如果在js文件是在aspx面里的话,好像可以直接调用。试下吧。
关键的地方就在 //提交注册信息
$.post("register.aspx?Data="+new Date(),{username:username,school:school,phone:phone,email:email,pwd:pwd}, function(data){
if(data=="1"){
window.location="register-success.html";
}else if(data=="2"){
alert("Email已存在");
}else{
alert("注册失败");
}
});data就是你在处理页面输出的东西,,直接Post不仅可以提交数据,还可以直接通过Data获取处理页面的结果输出。
还不明白问我 : [email protected]