回复 13楼xiyou的帖子代码已经极精简了,还是不行
@{
CurrentUser user = (CurrentUser)ViewBag.CurrentUser;
if(user.UserName == "")
{
<script type="text/javascript">
alert("您还未登录,请先登录。。。");
window.location.href="http://www.phycai.net/member";
</script>
}
}
<script type="text/javascript">
var token ='@user.UserToken';
alert(token);
postData("http://www.phycai.net/jrgwc","usertoken="+token+"&id=1");
function postData(url,data)
{
var xmlobj = new XMLHttpRequest();
xmlobj.open("POST", url, true);
xmlobj.setRequestHeader("cache-control","no-cache");
xmlobj.setRequestHeader("Content-Type", "text/html;charset=uft-8"); //指定发送的编码
xmlobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;"); //设置请求头信息
xmlobj.send(data); //设置为发送给服务器数据
xmlobj.onreadystatechange = function()
{
if(xmlobj.readyState == 4 && xmlobj.status == 200)
{
var rsp = xmlobj.responseText;
console.log(rsp);
}
};
};
</script>