2015-01-21 139 views
2
function setAction(){ 
    var value; 
    var id = document.getElementById('id').value; 
    if(document.getElementById('action1').checked==true){ 
    value = "Active" 
    } 
    else if(document.getElementById('action2').checked==true){ 
    value = "Inactive"; 
    } 
    else{ 
    value = "other"; 
    } 
    jConfirm('Are you continue?', 'Confirmation Dialog', function(r) { 
    if(r==true){ 
    var strURL="process.php?task=setActionProposal&id="+id+"&status="+value+"&value="+document.getElementById('other').value; 
    var req = getXMLHTTP(); 
    if (req) { 
     document.getElementById('loader').style.display='block' 
     req.onreadystatechange = function() { 
     if (req.readyState == 4) { 
      // only if "OK" 
      if (req.status == 200) { 
      //alert(req.responseText); 
      obj = JSON.parse(req.responseText); 
      if(obj.valid==true){ 
       document.getElementById('loader').style.display='none'; 
       window.location.href='user.php'; 
      } 
      } 
      else { 
      // alert("There was a problem while using XMLHTTP:\n" + req.statusText); 
      } 
     } 
     } 
     req.open("GET", strURL, true); 
     req.send(null); 
    } 
    } 
    else{ } 
    //jAlert('Confirmed: ' + r, 'Confirmation Results'); }); 
} 

我的页面没有进行重定向有什么不对的任何一个可以解决了,我需要与window.location.href='user.php';能不能够重新加载页面

+0

尝试'location.replace(“user.php”);' – 2015-01-21 06:43:14

+0

我做了,但它不工作我只是控制台,发现对象{帖子:数组[0],成功:假,味精:“没有找到记录”}}味精:“没有找到记录”的帖子:数组[0]成功:false__proto__:对象 – user4464505 2015-01-21 06:48:00

+0

您刚刚张贴不包含变量“有效”,因此代码将无法进入if语句的对象:'如果(obj.valid = = true){'可能你需要检查'obj.success'吗? – 2015-01-21 06:51:13

回答

0

重定向与您的完整项目路径 即尝试,

了window.location = '你的项目路径/ user.php的';

+0

是好的,但OBJ = JSON.parse(req.responseText);成功失败 – user4464505 2015-01-21 08:56:28

0

起初,
您检查,

window.location.href = 'http://www.google.com'; 

这将正常工作。 然后问题是你的项目路径。

相关问题