当前位置: 代码迷 >> Java Web开发 >> 简单传值有关问题,求教
  详细解决方案

简单传值有关问题,求教

热度:3409   发布时间:2013-02-25 21:06:48.0
简单传值问题,求教。
本帖最后由 yy330833493 于 2012-11-22 23:49:15 编辑

function guanzhu(aaa) {
    window.location.href = "concernLevel.do?id=" + aaa;
    var errorMsg = document.getElementById("errorMsg").value;
        if(errorMsg=="success")
           alert("关注成功");
      if(errorMsg=="failure")
       alert("请不要重复关注");
    }

点击按钮执行的js代码,concernLevel.do还是跳回自身画面,然后弹出alert内容。
问题是点击按钮的第一次,之跳转页面,不提示内容,以后点击正常。
因为第一次点击的时候errorMsg中没值,为什么,怎么改。
errorMsg中的值是在concernLevel.do中赋的,然后传到页面,用虚拟标签隐藏,再通过ID获取
用setAttribute试了总是报页面错误,不会写,求教。


$.ajax({
type:'POST',
        url: 'action名字',
data: {'loginName':loginName}, //参数 
dataType: 'text',
        error:....
        success:.....
})

  相关解决方案