Why my window.location.href doesn't work?

387 Views Asked by At

My codes are like this.

function deleteAction(obj,tableName){
    inputs=obj.parentNode.parentNode.getElementsByTagName("input");
    newValues="";

    for(i=0;i<inputs.length;i++){
        newValues+=inputs[i].value+",";
    }

    url="http://localhost:8081/SimpleWeb/SimpleServlet?action=delete&tableName="+tableName+"&newValue="+newValues;
    window.location.href=url;
}

I have made sure that that function will be run when I click on the button with Chrome's debug.

And the string url is valid because I can copy it to the browser and open the page correctly.

But in this function the window.location.href just doesn't work even if I change the url into "http://google.com"...Why

1

There are 1 best solutions below

0
On

is i variable global? After looking well, I suggest you change from this

 for(i=0;i<inputs.length;i++){
    newValues+=inputs[i].value+",";
 }

to

for(var j=0;j<inputs.length;j++){
    newValues+=inputs[j].value+",";
}