本篇文章给大家谈谈javascript获得post,以及javascript获得按键值对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
1、javascript如何获取post过来的值2、javascript如何获取post返回的数据?3、js怎么获取post传过来的值
javascript如何获取post过来的值
Query Ajax POST提交数据
JavaScript code?
$.post(“url”,data,callback);
例: $.post(“test.ashx”,{“uname”:$(“#txtuname”).val(),”pwd”:$(“#txtpwd”).val()},function(data,status){
if(status!=”success”){ return; }
alert(data);
});
后台接收数据
C# code?
string strUname = context.Request.Params.Get(“uname”);
string strPwd = context.Request.Params.Get(“pwd”);
if(!string.IsNullOrEmpty(strUname)!string.IsNullOrEmpty(strPwd))
{
//你的操作
}
javascript如何获取post返回的数据?
参数不可能没有数名称?post/get参数必须有名称,否则无法被服务器解析
例如:baidu.com/a/b?name=liage=10
1.baidu.com是域
2.a/b是路径,也称为路由路径
3.name/age是get参数
4.注意post参数也必须要key(即名称),不要以为使用post提交的参数就没有名称,只是默认不显示到浏览器地址栏而已
js怎么获取post传过来的值
post的值是不可能从html到hmtl的,中间必须经过Server.
原因:post的值是附加在http请求的头部的.只有在服务器端才能获得其值.
方案一:
使用asp在服务器端获得得post的值
如
Response.write request(“post的表单的name属性”)
方案二:
改用Get方式,通过URL传值
如2.html?aa=1
然后通过js获得得变量aa的值
SCRIPT LANGUAGE=JavaScript
!–
alert( GetQueryString(“aa”));
function GetQueryString(name)
{
var reg = new RegExp(“(^|)”+ name +”=([^]*)(|$)”);
var r = window.location.search.substr(1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
//–
/SCRIPT
“
关于javascript获得post和javascript获得按键值的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。