I am trying to pass a variable `userId` to my second page.

Here is the code piece I use to pass value to next page:

```
$.each($.parseJSON(data), function(key, value) {
    var userId = value.id_user;
    var stText = value.status_text;
    if (stText == "OK") {                  
        //if provide a valid username change the location 
        //to the specified page.
        window.location = "http://myurl.com/profile.php";
        window.location.href = "http://myurl.com/profile.php?userId=" + userId;
    }
});

```

But url looks like:

<http://myurl.com/profile.php?userId=undefined>